home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / shells / cshel500 / part01 next >
Encoding:
Internet Message Format  |  1991-03-03  |  65.2 KB

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i027: CShell 5.00 - alternative command interface, Part01/06
  4. Reply-To: <umueller@iiic.ethz.ch>
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i027@ab20.larc.nasa.gov>
  7. Date: 03 Mar 91 21:56:04 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga.misc
  11.  
  12. Submitted-by: <umueller@iiic.ethz.ch>
  13. Posting-number: Volume 91, Issue 027
  14. Archive-name: shells/cshell-5.00/part01
  15.  
  16. [ file `shell.doc' was split to facilitate posting  ...tad ]
  17.  
  18. Announcing: C-Shell 5.00
  19.  
  20. C-Shell 5.00 is a legitimate follow of the Matt Dillon shell.
  21.  
  22. Main features include:
  23. - Kickstart 2.0 compatible, some kick 2.0 specific features
  24. - 20 new built in commands
  25. - 70 functions like: echo @strleft( "hello world" 7 )
  26. - Many new system variables
  27. - Residentable (finally!)
  28. - Tab file name completion
  29. - Freely programmable editing keys
  30. - Object oriented features (file classes, actions on classes)
  31. - Jump scrolling for some internal commands
  32. - Automatic cd (type a directory name to 'cd' to it)
  33. - Quick cd ('cd' to any directory without typing a path)
  34. - Intuition Menus in the console window
  35. - VT terminal compatibility, command line editing on a VT
  36. - Foreign character sets supported
  37. - Automatic RX-ing (type a .rexx file name to 'rx' it)
  38. - Unlimited number of args & commands per line
  39.  
  40. Restrictions:
  41. - Due to the dramatic changes, certainly not 100% bug free. Everyday
  42.   use should not be affected. The first update fill follow soon; I 
  43.   count on your bug reports
  44. - Executable size 85K
  45.  
  46. #!/bin/sh
  47. # This is a shell archive.  Remove anything before this line, then unpack
  48. # it by saving it into a file and typing "sh file".  To overwrite existing
  49. # files, type "sh file -c".  You can also feed this as standard input via
  50. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  51. # will see the following message at the end:
  52. #        "End of archive 1 (of 6)."
  53. # Contents:  README class.sh globals.c lmakefile main.c makefile
  54. #   menu.sh proto.h run.c sample.sh set.c shell.doc.ac shell.h
  55. #   technotes.doc
  56. # Wrapped by tadguy@ab20 on Sun Mar  3 16:55:55 1991
  57. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  58. if test -f 'README' -a "${1}" != "-c" ; then 
  59.   echo shar: Will not clobber existing file \"'README'\"
  60. else
  61. echo shar: Extracting \"'README'\" \(1300 characters\)
  62. sed "s/^X//" >'README' <<'END_OF_FILE'
  63. XAnnouncing: C-Shell 5.00
  64. X
  65. XC-Shell 5.00 is a legitimate follow of the Matt Dillon shell.
  66. X
  67. XMain features include:
  68. X- Kickstart 2.0 compatible, some kick 2.0 specific features
  69. X- 20 new built in commands
  70. X- 70 functions like: echo @strleft( "hello world" 7 )
  71. X- Many new system variables
  72. X- Residentable (finally!)
  73. X- Tab file name completion
  74. X- Freely programmable editing keys
  75. X- Object oriented features (file classes, actions on classes)
  76. X- Jump scrolling for some internal commands
  77. X- Automatic cd (type a directory name to 'cd' to it)
  78. X- Quick cd ('cd' to any directory without typing a path)
  79. X- Intuition Menus in the console window
  80. X- VT terminal compatibility, command line editing on a VT
  81. X- Foreign character sets supported
  82. X- Automatic RX-ing (type a .rexx file name to 'rx' it)
  83. X- Unlimited number of args & commands per line
  84. X
  85. XRestrictions:
  86. X- Due to the dramatic changes, certainly not 100% bug free. Everyday
  87. X  use should not be affected. The first update fill follow soon; I 
  88. X  count on your bug reports
  89. X- Executable size 85K
  90. X
  91. X |          Urban Mueller         |      / / |    Urban Mueller    |
  92. X | USENET:  umueller@iiic.ethz.ch | __  / /  |    Schulhausstr. 83 |
  93. X | FIDONET: 2:302/906 (AUGL)      | \ \/ /   | CH-6312 Steinhausen |
  94. X | "Don't tell my employer"       |  \__/    |    SWITZERLAND      |
  95. X
  96. END_OF_FILE
  97. if test 1300 -ne `wc -c <'README'`; then
  98.     echo shar: \"'README'\" unpacked with wrong size!
  99. fi
  100. # end of 'README'
  101. fi
  102. if test -f 'class.sh' -a "${1}" != "-c" ; then 
  103.   echo shar: Will not clobber existing file \"'class.sh'\"
  104. else
  105. echo shar: Extracting \"'class.sh'\" \(1717 characters\)
  106. sed "s/^X//" >'class.sh' <<'END_OF_FILE'
  107. Xclass -n
  108. Xclass dms      offs=0,444D5321
  109. Xclass warp     offs=0,57617270
  110. Xclass zoom     offs=0,5A4F4F4D
  111. Xclass lharc    offs=2,2D6C68..2D
  112. Xclass zoo      offs=0,5A4F4F20
  113. Xclass arc      offs=0,1a08
  114. Xclass compr    offs=0,1f9d
  115. Xclass anim     offs=0,464f524d........414e494d
  116. Xclass icon     offs=0,e3100001 offs=0,f34c0012
  117. Xclass gif      offs=0,474946
  118. Xclass zip      offs=0,504b0304
  119. Xclass ppacked  offs=0,50503230
  120. X
  121. Xclass dms      suff=.dms act exec="Dms write" extr="Dms write" view="Dms view"
  122. Xclass warp     suff=.wrp act exec="Warp write 0 79" extr="Warp write 0 79"
  123. Xclass zoom     suff=.zom act exec="Zoom" extr="Zoom"
  124. Xclass lharc    suff=.lzh act exec="lharc e" extr="lharc e" view="lharc v" add="lharc a" edit=lharca
  125. Xclass zoo      suff=.zoo act exec="zoo e" extr="zoo e//" view="zoo v" add="zoo a"
  126. Xclass arc      suff=.arc act exec="arc e" extr="arc e" view="arc -v"
  127. Xclass zip      suff=.zip act exec="unzip" extr="unzip" view="unzip l"
  128. Xclass ppacked  suff=.pp  act exec="ppmore" view=ppmore
  129. Xclass lhwarp   suff=.lhw act exec="lhwarp write 0"
  130. Xclass anim     suff=.anim act exec=showanim view=showanim
  131. Xclass gif      suff=.gif  act exec=virtgif  view=virtgif extr="shamsharp"
  132. Xclass ilbm     offs=0,464F524D........494C424D act exec=M view=M edit=dpaint
  133. Xclass text     offs=0,464F524D........46545854 act edit=excellence
  134. Xclass prog     offs=0,000003f300000000 act view=htype edit=newzap
  135. Xclass object   suff=.o
  136. Xclass include  suff=.h
  137. Xclass c_source suff=.c
  138. Xclass script   suff=.sh
  139. Xclass ascii    suff=.doc suff=.txt name=readme chars act view=more exec=more edit=ced
  140. Xclass ""       default act view=htype edit=ced
  141. X
  142. Xalias v    "%n action -a view $n;more $n"
  143. Xalias ed   "%n action -a edit $n;ced $n"
  144. Xalias xt   "action extr"
  145. END_OF_FILE
  146. if test 1717 -ne `wc -c <'class.sh'`; then
  147.     echo shar: \"'class.sh'\" unpacked with wrong size!
  148. fi
  149. # end of 'class.sh'
  150. fi
  151. if test -f 'globals.c' -a "${1}" != "-c" ; then 
  152.   echo shar: Will not clobber existing file \"'globals.c'\"
  153. else
  154. echo shar: Extracting \"'globals.c'\" \(4589 characters\)
  155. sed "s/^X//" >'globals.c' <<'END_OF_FILE'
  156. X
  157. X/*
  158. X * GLOBALS.C
  159. X *
  160. X * (c)1986 Matthew Dillon     9 October 1986
  161. X *
  162. X *    Most global variables.
  163. X *
  164. X * Version 2.07M by Steve Drew 10-Sep-87
  165. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  166. X * Version 5.00L by Urban Mueller 17-Feb-91
  167. X *
  168. X */
  169. X
  170. X#include "shell.h"
  171. X
  172. Xchar v_titlebar    []="_titlebar";    /* Window title                        */
  173. Xchar v_prompt    []="_prompt";    /* your prompt (ascii command)        */
  174. Xchar v_hist        []="_history";    /* set history depth (value)        */
  175. Xchar v_histnum    []="_histnum";    /* set history numbering var        */
  176. Xchar v_debug    []="_debug";    /* set debug mode                    */
  177. Xchar v_verbose    []="_verbose";    /* set verbose for source files        */
  178. Xchar v_stat        []="_maxerr";    /* worst return value to date        */
  179. Xchar v_lasterr    []="_lasterr";    /* return value from last comm.        */
  180. Xchar v_cwd        []="_cwd";        /* current directory                */
  181. Xchar v_except    []="_except";    /* "nnn;command"                    */
  182. Xchar v_every    []="_every";    /* executed before prompt            */
  183. Xchar v_passed    []="_passed";    /* passed arguments to source file    */
  184. Xchar v_path        []="_path";        /* search path for external commands*/
  185. Xchar v_gotofwd    []="_gtf";        /* set name for fwd goto name        */
  186. Xchar v_linenum    []="_linenum";    /* name for forline line #            */
  187. Xchar v_lcd        []="_lcd";        /* last current directory            */
  188. Xchar v_rxpath    []="_rxpath";    /* path for .rexx commands            */
  189. Xchar v_hilite    []="_hilite";    /* hilighting escape sequence        */
  190. Xchar v_scroll    []="_scroll";    /* scroll jump in fast mode            */
  191. Xchar v_minrows    []="_minrows";    /* minimum # of rows for fast scroll*/
  192. Xchar v_result    []="_result";    /* result from rxsend                */
  193. Xchar v_qcd        []="_qcd";        /* file name for csh-qcd            */
  194. Xchar v_noreq    []="_noreq";    /* turn off system requesters        */
  195. Xchar v_value    []="_value";    /* return value of a function        */
  196. Xchar v_nobreak    []="_nobreak";    /* disabling of ^C                    */
  197. Xchar v_bground    []="_bground";    /* started in background            */
  198. X
  199. Xstruct HIST *H_head, *H_tail;    /* HISTORY lists */
  200. X
  201. Xstruct PERROR Perror[]= {    /* error code->string */
  202. X    103,    "Insufficient free storage",
  203. X    105,    "Task table full",
  204. X    120,    "Argument line invalid or too long",
  205. X    121,    "File is not an object module",
  206. X    122,    "Invalid resident library during load",
  207. X    201,    "No default directory",
  208. X    202,    "Object in use",
  209. X    203,    "Object already exists",
  210. X    204,    "Directory not found",
  211. X    205,    "Object not found",
  212. X    206,    "Bad stream name",
  213. X    207,    "Object too large",
  214. X    209,    "Action not known",
  215. X    210,    "Invalid stream component name",
  216. X    211,    "Invalid object lock",
  217. X    212,    "Object not of required type",
  218. X    213,    "Disk not validated",
  219. X    214,    "Disk write protected",
  220. X    215,    "Rename across devices",
  221. X    216,    "Directory not empty",
  222. X    217,    "Too many levels",
  223. X    218,    "Device not mounted",
  224. X    219,    "Seek error",
  225. X    220,    "Comment too long",
  226. X    221,    "Disk full",
  227. X    222,    "File delete protected",
  228. X    223,    "File write protected",
  229. X    224,    "File read protected",
  230. X    225,    "Not a DOS disk",
  231. X    226,    "No disk in drive",
  232. X
  233. X /* custom error messages */
  234. X
  235. X    500,    "Bad arguments",
  236. X    501,    "Label not found",
  237. X    502,    "Must be within source file",
  238. X    503,    "Syntax Error",
  239. X    504,    "Redirection error",
  240. X    505,    "Pipe error",
  241. X    506,    "Too many arguments",
  242. X    507,    "Destination not a directory",
  243. X    508,    "Cannot mv a filesystem",
  244. X    509,    "Error in command name",
  245. X    510,    "Bad drive name",
  246. X    511,    "Illegal number",
  247. X    512,    "Out of memory",
  248. X    0,    NULL
  249. X};
  250. X
  251. Xchar **av;                    /* Internal argument list                */
  252. XFILE *Src_base[MAXSRC];        /* file pointers for source files        */
  253. Xlong Src_pos[MAXSRC];        /* seek position storage for same        */
  254. Xint  Src_if[MAXSRC];        /* the if level at batch file start        */
  255. Xchar If_base[MAXIF];        /* If/Else stack for conditionals        */
  256. Xint H_len, H_tail_base;        /* History associated stuff                */
  257. Xint H_stack;                /* AddHistory disable stack                */
  258. Xint E_stack;                /* Exception disable stack                */
  259. Xint Src_stack, If_stack;    /* Stack Indexes                        */
  260. Xint forward_goto;            /* Flag for searching for foward lables    */
  261. Xint ac;                        /* Internal argc                        */
  262. Xint max_ac=256;                /* Maximum # of args (increasable)        */
  263. Xint debug;                    /* Debug mode                            */
  264. Xint disable;                /* Disable com. execution (conditionals)*/
  265. Xint Verbose;                /* Verbose mode for source files        */
  266. Xint Lastresult;                /* Last return code                        */
  267. Xint Exec_abortline;            /* flag to abort rest of line            */
  268. Xint Quit;                    /* Quit flag                            */
  269. Xlong Cout, Cin;                /* Current input and output file handles*/
  270. Xlong Cout_append;            /* append flag for Cout                    */
  271. Xchar *Cin_name, *Cout_name;    /* redirection input/output name or NULL*/
  272. Xchar *Pipe1, *Pipe2;        /* the two pipe temp. files                */
  273. Xstruct Process *Myprocess;
  274. Xstruct CommandLineInterface *Mycli;
  275. Xint S_histlen = 20;            /* Max # history entries                */
  276. X
  277. Xunsigned int options;
  278. Xchar Buf[280], confirmed;
  279. XCLASS *CRoot, *LastCRoot;
  280. END_OF_FILE
  281. if test 4589 -ne `wc -c <'globals.c'`; then
  282.     echo shar: \"'globals.c'\" unpacked with wrong size!
  283. fi
  284. # end of 'globals.c'
  285. fi
  286. if test -f 'lmakefile' -a "${1}" != "-c" ; then 
  287.   echo shar: Will not clobber existing file \"'lmakefile'\"
  288. else
  289. echo shar: Extracting \"'lmakefile'\" \(1339 characters\)
  290. sed "s/^X//" >'lmakefile' <<'END_OF_FILE'
  291. X######################################################################
  292. X#
  293. X# Makefile to build Shell 5.00A under Lattice C 5.10
  294. X# NOTE: Our char's are UNSIGNED by default!
  295. X#
  296. X######################################################################
  297. X
  298. XFLAGS    = -ms -v -d3 -cu -cs -O
  299. XPRECOM    =
  300. X#PRECOM    = -HShell.syms
  301. X
  302. X# -ms = short code
  303. X# -v  = no stack overflow check
  304. X# -d0 = no debug info
  305. X# -cu = unsigned chars
  306. X# -cs = no copies of string
  307. X# -m3 = code for 68030
  308. X# -H  = read precompiled header file
  309. X
  310. X
  311. X
  312. XOBJS    = run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o \
  313. X      globals.o rawcon.o
  314. X
  315. XINCL    = shell.h
  316. X
  317. Xcsh   : makefile $(OBJS)
  318. X    BLINK lib:cres.o $(OBJS) LIB lib:lc.lib lib:amiga.lib TO csh NOICONS ND
  319. X
  320. X#shell.syms: Shell.h Proto.h
  321. X#    lc -cu -ph -oShell.Syms Syms.c
  322. X
  323. Xrawcon.o : rawcon.c $(INCL)
  324. X    lc $(FLAGS) $(PRECOM) rawcon.c
  325. X
  326. Xrun.o   : run.c $(INCL)
  327. X    lc $(FLAGS) $(PRECOM) run.c
  328. X
  329. Xmain.o  : main.c $(INCL)
  330. X    lc $(FLAGS) $(PRECOM) main.c
  331. X
  332. Xcomm1.o : comm1.c $(INCL)
  333. X    lc $(FLAGS) $(PRECOM) comm1.c
  334. X
  335. Xcomm2.o : comm2.c $(INCL)
  336. X    lc $(FLAGS) $(PRECOM) comm2.c
  337. X
  338. Xcomm3.o : comm3.c $(INCL)
  339. X    lc $(FLAGS) $(PRECOM) comm3.c
  340. X
  341. Xset.o   : set.c $(INCL)
  342. X    lc $(FLAGS) $(PRECOM) set.c
  343. X
  344. Xsub.o   : sub.c $(INCL)
  345. X    lc $(FLAGS) $(PRECOM) sub.c
  346. X
  347. Xglobals.o : globals.c $(INCL)
  348. X    lc $(FLAGS) $(PRECOM) globals.c
  349. X
  350. Xexecom.o : execom.c $(INCL)
  351. X    lc $(FLAGS) $(PRECOM) execom.c
  352. END_OF_FILE
  353. if test 1339 -ne `wc -c <'lmakefile'`; then
  354.     echo shar: \"'lmakefile'\" unpacked with wrong size!
  355. fi
  356. # end of 'lmakefile'
  357. fi
  358. if test -f 'main.c' -a "${1}" != "-c" ; then 
  359.   echo shar: Will not clobber existing file \"'main.c'\"
  360. else
  361. echo shar: Extracting \"'main.c'\" \(8799 characters\)
  362. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  363. X/*
  364. X * MAIN.C
  365. X *
  366. X * Matthew Dillon, 24 Feb 1986
  367. X * (c)1986 Matthew Dillon     9 October 1986
  368. X *
  369. X * Version 2.07M by Steve Drew 10-Sep-87
  370. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  371. X * Version 5.00L by Urban Mueller 17-Feb-91
  372. X *
  373. X */
  374. X
  375. X#include "shell.h"
  376. X
  377. Xvoid breakreset(void);
  378. Xstruct Window *getwindow (void);
  379. X
  380. Xchar shellname[]   ="CShell V5.00L";
  381. Xchar shellversion[]="500";
  382. Xchar shellvers[]   ="5.00";
  383. Xchar shellctr []   ="CshCounter";
  384. Xchar shellres []   ="CshResident";
  385. Xchar shellv   []   ="\0$VER: csh 5.00";
  386. X
  387. Xstatic void add_residents(void);
  388. X
  389. Xchar *oldtitle;
  390. Xchar trueprompt[100];
  391. Xchar Inline[260];
  392. Xstruct IntuitionBase *IntuitionBase;
  393. Xstruct Window *Win;
  394. Xstruct ArpBase *ArpBase;
  395. Xint    oldtaskpri=-999;
  396. X
  397. Xstatic char *defset[]={
  398. X    v_histnum,  "0",
  399. X    v_titlebar, shellname,
  400. X    v_hist,     "50",
  401. X    v_lasterr,  "0",
  402. X    v_stat,     "0",
  403. X    v_path,     "RAM:,RAM:c,df0:c,df1:c,sys:system",
  404. X    v_rxpath,   "REXX:",
  405. X    v_scroll,   "3",
  406. X    v_minrows,  "34",
  407. X    v_hilite,   "c7",
  408. X    v_lcd,      "",
  409. X    v_qcd,      "s:csh-qcd",
  410. X    "_terminal","",
  411. X    "_man",     "shell.doc",
  412. X    "_insert",  "1",
  413. X    "_version", shellversion,
  414. X    "f1",       "cdir df0:\15",
  415. X    "F1",       "cdir df1:\15",
  416. X    "f3",       "cdir RAM:\15",
  417. X    "F3",       "cdir vd0:\15",
  418. X    "f4",       "cd df0:\15",
  419. X    "F4",       "cd df1:\15",
  420. X    "f5",       "cls; ls\15",
  421. X    "F5",       "cdir ",
  422. X    "f6",       "ls -s\15",
  423. X    "f7",       "info\15",
  424. X    "F7",       "assign \15",
  425. X    "f8",       "window -lf\15",
  426. X    "F8",       "window -sb\15",
  427. X    "f10",      "cls\15",
  428. X    "F10",      "exit\15",
  429. X    NULL,       NULL
  430. X};
  431. X
  432. Xstatic char *defalias[]={
  433. X    "cdir", "%q cd $q; cls; dir",
  434. X    "cls",  "echo -n ^l",
  435. X    "diffdir","dir -u",
  436. X    "dswap","cd $_lcd",
  437. X    "exit", "endcli;quit",
  438. X    "fg",   "pri 0 1",
  439. X    "kr",   "rm -r RAM:* >NIL:",
  440. X    "nice", "pri 0 -1",
  441. X    "lp",   "cat >PRT:",
  442. X    "q",    "quit",
  443. X    "manlist", "sea -qwnl $_man \"    *\"",
  444. X    NULL,   NULL
  445. X};
  446. X
  447. X#ifndef AZTEC_C
  448. Xchkabort()
  449. X{
  450. X    return 0;
  451. X}
  452. X#endif
  453. X
  454. Xextern struct Library *DosBase;
  455. X
  456. Xmain(argc, argv)
  457. Xchar *argv[];
  458. X{
  459. X    int i;
  460. X    char buf[10];
  461. X    static char pipe1[32], pipe2[32];
  462. X    struct Window *getwindow();
  463. X    char nologin=0 , *mymem=malloc(4);
  464. X#ifdef AZTEC_C
  465. X    extern int Enable_Abort;
  466. X    Enable_Abort = 0;
  467. X#endif
  468. X
  469. X    if( argc==0 )               /* Prevent starting from workbench */
  470. X        exit(0);
  471. X
  472. X    if( !(av=malloc( max_ac*sizeof(char *)))) exit( 0 );
  473. X
  474. X    initmap();
  475. X
  476. X    if(!(ArpBase=(struct ArpBase *)OpenLibrary("arp.library",34L)))
  477. X        { printf("No arp library\n"); exit(0); }
  478. X
  479. X    IntuitionBase=(struct IntuitionBase *)ArpBase->IntuiBase;
  480. X
  481. X    if( ArpBase->DosBase->lib_Version >= 36 )
  482. X        o_kick20=1;
  483. X    set_var( LEVEL_SET, "_kick2x", (o_kick20) ? "1" : "0" );
  484. X
  485. X    if( !IsInteractive(Input()))
  486. X        o_bground=1;
  487. X    set_var( LEVEL_SET, v_bground, (o_bground) ? "1" : "0" );
  488. X
  489. X
  490. X    Forbid();
  491. X    i=0;
  492. X    if (Getenv(shellctr,buf,10L)) i=atoi(buf);
  493. X    if (Getenv(shellres,buf,10L)) o_resident=1;
  494. X    sprintf(buf, "%d", i+1);
  495. X    Setenv(shellctr, buf);
  496. X    Permit();
  497. X
  498. X#ifdef isalphanum
  499. X    for( i='a'; i<='z'; i++ )
  500. X        isalph[i]=1;
  501. X    for( i='A'; i<='Z'; i++ )
  502. X        isalph[i]=1;
  503. X    for( i='0'; i<='9'; i++ )
  504. X        isalph[i]=1;
  505. X    isalph['_']=1;
  506. X#endif
  507. X
  508. X#ifdef AZTEC_C
  509. X    stdin->_flags    |= _IONBF;    /* make sure we're set as an unbuffered tty */
  510. X    stdout->_flags    |= _IONBF;    /* in case of redirection in .login */
  511. X    Close(_devtab[2].fd);
  512. X    _devtab[2].mode |= O_STDIO;
  513. X    _devtab[2].fd = _devtab[1].fd;    /* set stderr to Output() otherwise */
  514. X                    /* don't work with aux driver */
  515. X#else
  516. X    /* if( setvbuf( stdout,NULL,_IOLBF,BUFSIZ )) exit(20); */
  517. X    /* setnbf( stdout ); */
  518. X    /* Close( _ufbs[2] ); */
  519. X    /*_ufbs[2]=_ufbs[1]; */
  520. X    /* setnbf( stderr ); */
  521. X#endif
  522. X
  523. X    Myprocess = (struct Process *)FindTask(0L);
  524. X    Mycli=(struct CommandLineInterface *)((long)Myprocess->pr_CLI << 2);
  525. X
  526. X    if( !o_nowindow && (Win=getwindow()) && IsInteractive(Input())) {
  527. X        oldtitle=(char *)(Win->Title);
  528. X        set_menu();
  529. X    }
  530. X
  531. X    Pipe1 = pipe1;
  532. X    Pipe2 = pipe2;
  533. X    sprintf(pipe1, "t:pipe1_%ld", mymem);
  534. X    sprintf(pipe2, "t:pipe2_%ld", mymem);
  535. X
  536. X    sprintf(buf,"%ld",Myprocess->pr_TaskNum);
  537. X    set_var(LEVEL_SET, "_clinumber", buf);
  538. X
  539. X    seterr();
  540. X    if (Myprocess->pr_CurrentDir == NULL)
  541. X        do_cd("x :");
  542. X    else do_pwd(NULL);
  543. X
  544. X    o_nowindow= 1;
  545. X
  546. X    set_var(LEVEL_SET,v_prompt, (IsInteractive(Input())) ? "%c%p> ":"");
  547. X    for( i=0; defset[i]; i+=2 )
  548. X        set_var( LEVEL_SET, defset[i], defset[i+1] );
  549. X    for( i=0; defalias[i]; i+=2 )
  550. X        set_var( LEVEL_ALIAS, defalias[i], defalias[i+1] );
  551. X
  552. X    o_nowindow= 0;
  553. X
  554. X    for (i = 1; i < argc; ++i) {
  555. X        if (*argv[i]=='-') {
  556. X            char *str=argv[1];
  557. X
  558. X            if( index(str,'k') ) set_var(LEVEL_SET,v_nobreak,"1");
  559. X            if( index(str,'i') ) o_internal=1;
  560. X            if( index(str,'r') ) add_residents();
  561. X            if( index(str,'v') ) Verbose=1, set_var(LEVEL_SET,v_verbose,"1");
  562. X            if( index(str,'n') ) nologin=TRUE;
  563. X            if( index(str,'b') ) {
  564. X                oldtaskpri=Myprocess->pr_Task.tc_Node.ln_Pri;
  565. X                SetTaskPri( &Myprocess->pr_Task, -1 );
  566. X            }
  567. X            if( index(str,'f') ) {
  568. X                oldtaskpri=Myprocess->pr_Task.tc_Node.ln_Pri;
  569. X                SetTaskPri( &Myprocess->pr_Task,  1 );
  570. X            }
  571. X            if( index(str,'c') ) {
  572. X                Inline[0] = ' ';
  573. X                Inline[1] = '\0';
  574. X                while (++i < argc)
  575. X                    { strcat(Inline,argv[i]); strcat(Inline," "); }
  576. X                exec_command(Inline);
  577. X                main_exit(Lastresult);
  578. X            }
  579. X            if( index(str,'a')) {
  580. X                o_nowindow= o_noraw= 1;
  581. X                set_var( LEVEL_SET, v_hilite, "" );
  582. X            }
  583. X            if( index(str,'t')) {
  584. X                o_nowindow= o_vt100= o_nofastscr= 1;
  585. X                /*       clr     */
  586. X                set_var( LEVEL_SET, v_hilite, "r" );
  587. X                set_var( LEVEL_SET, v_noreq, "1" );
  588. X                set_var( LEVEL_SET, "_terminal", "1" );
  589. X                set_var( LEVEL_ALIAS, "cls", "e -n ^[[0\\;0H^[[J" );
  590. X            }
  591. X        } else {
  592. X            sprintf (Inline, "source %s",argv[i]);
  593. X            av[1] = argv[i];
  594. X            do_source (Inline);
  595. X        }
  596. X    }
  597. X
  598. X    if (!nologin && exists(av[1] = "S:.login")) do_source("x S:.login");
  599. X
  600. X    for (;;) {
  601. X        if (breakcheck())
  602. X#ifdef AZTEC_C
  603. X        while (WaitForChar(Input(), 100L) || stdin->_bp < stdin->_bend)
  604. X#else
  605. X        while (WaitForChar(Input(), 100L) || stdin->_rcnt != stdin->_wcnt )
  606. X#endif
  607. X            gets(Inline);
  608. X        clearerr(stdin);  /* prevent acidental quit */
  609. X        exec_every();
  610. X        update_sys_var(v_titlebar);
  611. X        update_sys_var(v_prompt);
  612. X        breakreset();
  613. X#if RAW_CONSOLE
  614. X        if (Quit || !rawgets(Inline, disable ? "_ " : trueprompt)) main_exit(0);
  615. X#else
  616. X        printf("%s", disable ? "_ " : trueprompt);
  617. X        fflush(stdout);
  618. X        if (Quit || !gets(Inline)) main_exit(0);
  619. X#endif
  620. X        breakreset();
  621. X        if (*Inline) exec_command(Inline);
  622. X    }
  623. X}
  624. X
  625. Xvoid
  626. Xmain_exit(n)
  627. X{
  628. X    int i;
  629. X    char buf[10];
  630. X
  631. X    Getenv(shellctr,buf,10L);
  632. X    i=atoi(buf);
  633. X    sprintf(buf,"%d",i-1);
  634. X    Setenv(shellctr,buf);
  635. X    if( oldtitle )
  636. X        SetWindowTitles(Win,oldtitle,(char *)-1);
  637. X    if( oldtaskpri != -999 )
  638. X        SetTaskPri(&Myprocess->pr_Task,oldtaskpri);
  639. X    for (i=1; i<MAXMYFILES; i++) myclose(i);
  640. X    remove_menu();
  641. X    CloseLibrary((struct Library *)ArpBase);
  642. X    exit(0);
  643. X}
  644. X
  645. Xint
  646. Xbreakcheck()
  647. X{
  648. X    return !o_nobreak && SetSignal(0L,0L) & SIGBREAKF_CTRL_C;
  649. X}
  650. X
  651. Xvoid
  652. Xbreakreset()
  653. X{
  654. X    SetSignal(0L, SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D);
  655. X}
  656. X
  657. Xdobreak()
  658. X{
  659. X    if (breakcheck()) { printf("^C\n"); return(1); }
  660. X    return(0);
  661. X}
  662. X
  663. X/* this routine causes manx to use this Chk_Abort() rather than it's own */
  664. X/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
  665. X/* is zero).  Since we want to check for our own ^C's             */
  666. X
  667. Xlong
  668. XChk_Abort()
  669. X{
  670. X    return(0);
  671. X}
  672. X
  673. Xvoid
  674. X_wb_parse()
  675. X{
  676. X}
  677. X
  678. Xdo_howmany()
  679. X{
  680. X    char buf[10];
  681. X
  682. X    Getenv(shellctr, buf, 10L);
  683. X    printf("Shell(s) running: %s\n",buf);
  684. X    return 0;
  685. X}
  686. X
  687. Xstatic struct Window *
  688. Xgetwindow()
  689. X{
  690. X    struct InfoData *infodata;
  691. X    struct Window *win;
  692. X    long args[8];
  693. X
  694. X    if( o_nowindow )
  695. X        return NULL;
  696. X    infodata=(void *)AllocMem((long)sizeof(struct InfoData),MEMF_CLEAR|MEMF_PUBLIC);
  697. X    args[0]=(long)infodata >> 2;
  698. X    Write(Output(),"",1);        /* make window appear */
  699. X    SendPacket(ACTION_DISK_INFO,args,(void *)Myprocess->pr_ConsoleTask);
  700. X    win=(struct Window *)infodata->id_VolumeNode;
  701. X    FreeMem(infodata,(long)sizeof(struct InfoData));
  702. X    if( win==NULL )
  703. X        o_nowindow=1;
  704. X    newwidth();
  705. X    return win;
  706. X}
  707. X
  708. X#ifndef AZTEC_C
  709. X
  710. Xchar *
  711. Xrindex( char *str , char c )
  712. X{
  713. X    char *ret=NULL;
  714. X
  715. X    for( ; *str; str++ )
  716. X        if( *str==c )
  717. X            ret=str;
  718. X    return ret;
  719. X}
  720. X
  721. X#endif
  722. X
  723. Xextern struct DosLibrary *DOSBase;
  724. X
  725. Xstruct ResidentList {
  726. X    BPTR rl_Next;
  727. X    LONG rl_UseCount;
  728. X    BPTR rl_SegList;
  729. X    char rl_SegName[1];
  730. X};
  731. X
  732. X
  733. Xstatic void
  734. Xadd_residents()
  735. X{
  736. X    char buf[80], *g, *p, c;
  737. X    struct RootNode *Node;
  738. X    struct DosInfo  *Info;
  739. X    struct ResidentList *res;
  740. X    struct ResidentProgramNode *rpn;
  741. X
  742. X    if( ArpBase->ResidentPrgList )
  743. X        return;
  744. X
  745. X    Forbid(); 
  746. X    Node=(struct RootNode *)DOSBase->dl_Root;
  747. X    Info=(struct DosInfo  *)(Node->rn_Info*4);
  748. X    res=(struct ResidentList *)((long)Info->di_NetHand*4);
  749. X
  750. X    for( ; res; res=(struct ResidentList *)((long)res->rl_Next*4) ) {
  751. X        g=res->rl_SegName, p=buf;
  752. X        for( c=*g++; c>0; --c ) *p++=*g++;
  753. X        *p=0;
  754. X        if( res->rl_UseCount>=0 )
  755. X            res->rl_UseCount++;
  756. X        else
  757. X            continue;
  758. X        AddResidentPrg( res->rl_SegList, buf);
  759. X        for(rpn=ArpBase->ResidentPrgList; rpn; rpn=rpn->rpn_Next)
  760. X            if( rpn->rpn_Segment==res->rl_SegList )
  761. X                rpn->rpn_Usage++;
  762. X    }
  763. X    Permit();
  764. X}
  765. END_OF_FILE
  766. if test 8799 -ne `wc -c <'main.c'`; then
  767.     echo shar: \"'main.c'\" unpacked with wrong size!
  768. fi
  769. # end of 'main.c'
  770. fi
  771. if test -f 'makefile' -a "${1}" != "-c" ; then 
  772.   echo shar: Will not clobber existing file \"'makefile'\"
  773. else
  774. echo shar: Extracting \"'makefile'\" \(1302 characters\)
  775. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  776. X######################################################################
  777. X#
  778. X# Makefile to build Shell 5.00  under Aztec C 5.0d
  779. X# make sure you use 5.0d or above, as setenv() has changed
  780. X# NOTE: Our chars are UNSIGNED by default!
  781. X#
  782. X######################################################################
  783. X
  784. XOBJS    = run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o \
  785. X      globals.o rawcon.o
  786. X
  787. XINCL    = shell.syms
  788. X
  789. XERRFILE    =
  790. XFLAGS    = -pp -wurp -ssr $(ERRFILE)
  791. XDEBUG    = -bs
  792. XPRECOM    = -hiShell.syms
  793. X
  794. Xcsh:  makefile shell.syms $(OBJS)
  795. X    ln  +q -m -g -o csh $(OBJS) -larpl -lc
  796. X
  797. Xshell.syms : shell.h proto.h
  798. X    cc -pp -hoShell.syms shell.h -DAZTEC_C
  799. X
  800. Xrawcon.o : rawcon.c $(INCL)
  801. X    cc $(DEBUG) $(FLAGS) $(PRECOM) rawcon.c
  802. X
  803. Xrun.o   : run.c $(INCL)
  804. X    cc $(DEBUG) $(FLAGS) $(PRECOM) run.c
  805. X
  806. Xmain.o  : main.c $(INCL)
  807. X    cc $(DEBUG) $(FLAGS) $(PRECOM) main.c
  808. X
  809. Xcomm1.o : comm1.c $(INCL)
  810. X    cc $(DEBUG) $(FLAGS) $(PRECOM) comm1.c
  811. X
  812. Xcomm2.o : comm2.c $(INCL)
  813. X    cc $(DEBUG) $(FLAGS) $(PRECOM) comm2.c
  814. X
  815. Xcomm3.o : comm3.c $(INCL)
  816. X    cc $(DEBUG) $(FLAGS) $(PRECOM)  comm3.c
  817. X
  818. Xset.o   : set.c $(INCL)
  819. X    cc $(DEBUG) $(FLAGS) $(PRECOM) set.c
  820. X
  821. Xsub.o   : sub.c $(INCL)
  822. X    cc $(DEBUG) $(FLAGS) $(PRECOM) sub.c
  823. X
  824. Xglobals.o : globals.c $(INCL)
  825. X    cc $(DEBUG) $(FLAGS) $(PRECOM) globals.c
  826. X
  827. Xexecom.o : execom.c $(INCL)
  828. X    cc $(DEBUG) $(FLAGS) $(PRECOM) execom.c
  829. END_OF_FILE
  830. if test 1302 -ne `wc -c <'makefile'`; then
  831.     echo shar: \"'makefile'\" unpacked with wrong size!
  832. fi
  833. # end of 'makefile'
  834. fi
  835. if test -f 'menu.sh' -a "${1}" != "-c" ; then 
  836.   echo shar: Will not clobber existing file \"'menu.sh'\"
  837. else
  838. echo shar: Extracting \"'menu.sh'\" \(982 characters\)
  839. sed "s/^X//" >'menu.sh' <<'END_OF_FILE'
  840. X# This installs an intuition menu with all editing keys
  841. X
  842. Xmenu -n Move \
  843. X "Left         CursL",\
  844. X "Right        CursR",\
  845. X "WordLeft   S-CursL",\
  846. X "WordRight  S-CursR",\
  847. X "BegOfLine       ^A",^a\
  848. X "EndOfLine       ^E",^e
  849. X
  850. Xmenu  Delete \
  851. X "Left         BkSpc",^h\
  852. X "Right          Del",\177\
  853. X "WordLeft        ^W",^[^h\
  854. X "WordRight  ESC-Del",^[\177\
  855. X "To BOL          ^B",^[x^h\
  856. X "To EOL          ^K",^[x\177\
  857. X "Line            ^X",^[d
  858. X
  859. Xmenu History \
  860. X "Back         CursU",\
  861. X "Forward      CursD",\
  862. X "Start      S-CursU",\
  863. X "End        S-CursD",\
  864. X "Complete     ESC-!",^[!\
  865. X "Get tail        ^T",^T
  866. X
  867. Xmenu Complete \
  868. X "One            TAB",^I\
  869. X "Partial      S-TAB",\
  870. X "All        ESC-TAB",^[^I\
  871. X "QuickCD      ESC-c",^[c\
  872. X "LastCD       ESC-~",^[~
  873. X
  874. Xmenu Execute \
  875. X "Now         RETURN",^M\
  876. X "+Hist   ESC-RETURN",^[^M\
  877. X "Not             ^N",^N\
  878. X "Exit            ^\",
  879. X
  880. Xmenu Misc \
  881. X "Undo            ^U",^U\
  882. X "Repeat          ^R",^R\
  883. X "Retype          ^L",^L\
  884. X "Ins/Ovr      ESC-i",^[i
  885. X
  886. END_OF_FILE
  887. if test 982 -ne `wc -c <'menu.sh'`; then
  888.     echo shar: \"'menu.sh'\" unpacked with wrong size!
  889. fi
  890. # end of 'menu.sh'
  891. fi
  892. if test -f 'proto.h' -a "${1}" != "-c" ; then 
  893.   echo shar: Will not clobber existing file \"'proto.h'\"
  894. else
  895. echo shar: Extracting \"'proto.h'\" \(5157 characters\)
  896. sed "s/^X//" >'proto.h' <<'END_OF_FILE'
  897. X/* main.c */
  898. Xint main(int argc, char **argv);
  899. Xvoid main_exit(int n);
  900. Xint breakcheck(void);
  901. Xint dobreak(void);
  902. Xlong Chk_Abort(void);
  903. Xvoid _wb_parse(void);
  904. Xint do_howmany(void);
  905. Xvoid breakreset(void);
  906. X
  907. X/* comm1.c */
  908. Xint do_sleep(void);
  909. Xint do_protect(void);
  910. Xint do_filenote(void);
  911. Xint do_cat(void);
  912. Xvoid get_drives(char *buf);
  913. Xchar *drive_name(char *name);
  914. Xchar *oneinfo( char *name, int function );
  915. Xint do_info(void);
  916. Xint do_dir(void);
  917. Xchar *formatfile(struct file_info *info);
  918. Xint do_quit(void);
  919. Xint do_echo(void);
  920. Xint do_source(char *str );
  921. Xint do_pwd(char *str );
  922. Xint do_cd(char *str );
  923. Xchar *quick_cd( char *buf, char *name, int repeat );
  924. Xint do_mkdir(void);
  925. Xint do_mv(void);
  926. Xint all_args(int (*action)(char *str), int dirsflag);
  927. Xint do_search(void);
  928. Xint do_rm(void);
  929. Xint do_history(void);
  930. Xint do_mem(void);
  931. Xint do_forline(void);
  932. Xint do_fornum(void);
  933. Xint do_foreach(void);
  934. Xint do_forever(char *str);
  935. Xint do_window(void);
  936. Xchar *dates(struct DateStamp *dss);
  937. Xint do_date(void);
  938. X
  939. X/* comm2.c */
  940. Xint do_abortline(void);
  941. Xint do_return(void);
  942. Xint do_strhead(void);
  943. Xint do_strtail(void);
  944. Xint do_if(char *garbage, int com);
  945. Xint do_label(void);
  946. Xint do_goto(void);
  947. Xint do_inc(char *garbage, int com);
  948. Xint do_input(void);
  949. Xint do_ver(void);
  950. Xint do_ps(void);
  951. Xint do_copy(void);
  952. Xint do_touch(void);
  953. Xint do_addbuffers(void);
  954. Xint do_relabel(void);
  955. Xint do_diskchange(void);
  956. Xint dofunc(int id, char **av, int ac);
  957. X
  958. X/* comm3.c */
  959. Xint do_tee(void);
  960. Xint do_head(char *garbage, int com);
  961. Xvoid man(struct __stdio *f, char *s);
  962. Xint do_man(void);
  963. Xint do_assign(void);
  964. Xint do_join(void);
  965. Xint do_strings(void);
  966. Xint do_open(void);
  967. Xint do_close(void);
  968. Xvoid myclose(int n);
  969. Xint do_fileslist(void);
  970. Xlong extOpen(char *name, long mode);
  971. Xvoid extClose(long fh);
  972. Xint do_basename(void);
  973. Xint do_tackon(void);
  974. Xint do_resident(void);
  975. Xint loadres(char *s);
  976. Xint do_truerun(char *avline, int backflag);
  977. Xint exists(char *name);
  978. Xint do_aset(void);
  979. Xint do_htype(void);
  980. Xint do_stack(void);
  981. Xint do_fault(void);
  982. Xint eval_rpn(char **av, int ac, int flag);
  983. Xint do_rpn(char *garbage, int ifflag);
  984. Xint do_path(void);
  985. Xint do_pri(void);
  986. Xint do_strleft(void);
  987. Xint do_strright(void);
  988. Xint do_strmid(void);
  989. Xint do_strlen(void);
  990. Xint myatoi(char *s, int min, int max);
  991. Xint unlatoi(char *s);
  992. Xint posatoi(char *s);
  993. Xint do_fltlower(void);
  994. Xint do_fltupper(void);
  995. Xint do_linecnt(void);
  996. Xint do_uniq(void);
  997. Xint do_rxsend(char *avline);
  998. Xint do_rxrec(void);
  999. Xint do_rxreturn(void);
  1000. Xint do_waitport(void);
  1001. Xint do_ascii(void);
  1002. Xvoid appendslash(char *path);
  1003. Xint do_whereis(void);
  1004. Xint do_usage(void);
  1005. Xint do_menu(void);
  1006. Xvoid remove_menu(void);
  1007. Xvoid set_menu(void);
  1008. Xint do_getenv(void);
  1009. Xint do_setenv(void);
  1010. Xchar **read_file(struct __stdio *file, int *ac);
  1011. Xvoid free_file(char **ptr);
  1012. Xint do_qsort(void);
  1013. Xint do_truncate(void);
  1014. Xint do_split(void);
  1015. X
  1016. X/* execom.c */
  1017. Xvoid *mymalloc(int len);
  1018. Xint exec_command(char *base);
  1019. X#ifndef isalphanum
  1020. Xint isalphanum(char c);
  1021. X#endif
  1022. Xchar *exec_function(char *str, char **fav, int fac);
  1023. Xint do_help(void);
  1024. Xvoid exec_every(void);
  1025. Xvoid show_usage(char *str);
  1026. Xint do_exec(char *str);
  1027. Xint interactive(void);
  1028. Xchar *a0tospace(char *str);
  1029. Xint execute( char *str );
  1030. Xchar *find_internal(char *str);
  1031. X
  1032. X/* sub.c */
  1033. Xchar *getclass(char *file);
  1034. Xvoid seterr(void);
  1035. Xchar *next_word(char *str);
  1036. Xchar *compile_av(char **av, int start, int end, char delim, int quote);
  1037. Xvoid Free(void *ptr);
  1038. Xvoid add_history(char *str);
  1039. Xchar *get_history(char *ptr, int echo);
  1040. Xvoid replace_head(char *str);
  1041. Xvoid pError(char *str);
  1042. Xint ierror(char *str, int err);
  1043. Xstruct DPTR *dopen(char *name, int *stat);
  1044. Xint dclose(struct DPTR *dp);
  1045. Xint isdir(char *file);
  1046. Xvoid free_expand(char **av);
  1047. Xchar **expand(char *base, int *pac);
  1048. Xchar *strupr(char *s);
  1049. Xchar *strlwr(char *s);
  1050. Xint compare_ok(char *wild, char *name, int casedep);
  1051. Xvoid expand_all(char *name, struct __stdio *file);
  1052. Xint cmp(char *s1, char *s2);
  1053. Xint sizecmp(char *s1, char *s2);
  1054. Xint datecmp(char *s1, char *s2);
  1055. Xint classcmp(char *s1, char *s2);
  1056. Xvoid QuickSort(char **av, int n);
  1057. Xvoid DirQuickSort(char **av, int n, int (*func)(char *,char *), int rev);
  1058. Xint filesize(char *name);
  1059. Xchar **and(char **av1, int ac1, char **av2, int ac2, int *ac, int base);
  1060. Xchar **without(char **av1, int ac1, char **av2, int ac2, int *ac, int base);
  1061. Xchar **or(char **av1, int ac1, char **av2, int ac2, int *ac, int base);
  1062. Xvoid clear_archive_bit(char *name);
  1063. Xchar *itoa( int i );
  1064. Xchar *itok( int i );
  1065. Xchar *getaction( char *class, char *action );
  1066. Xint doaction( char *file, char *action, char *args );
  1067. X
  1068. X/* set.c */
  1069. Xvoid set_var(int level, char *name, char *str);
  1070. Xvoid update_sys_var( char *name );
  1071. Xvoid set_var_n(int level, char *name, char *str, int n);
  1072. Xchar *get_var(int level, char *name);
  1073. Xvoid unset_level(int level);
  1074. Xvoid unset_var(int level, char *name);
  1075. Xint do_unset_var(char *str, int level);
  1076. Xint do_set_var(char *command, int level);
  1077. X
  1078. X/* rawconsole.c */
  1079. Xint newwidth(void);
  1080. Xvoid initmap(void);
  1081. Xchar *rawgets(char line[], char prompt[]);
  1082. Xvoid prepscroll(int fromtee);
  1083. Xvoid quickscroll(void);
  1084. Xvoid setrawcon( long flag, int ievent );
  1085. X
  1086. X/* run.c */
  1087. Xint do_run(char *str);
  1088. Xchar *dofind(char *cmd, char *ext, char *buf, char *path);
  1089. X#ifndef AZTEC_C
  1090. Xchar *rindex( char *str , char c );
  1091. X#endif
  1092. END_OF_FILE
  1093. if test 5157 -ne `wc -c <'proto.h'`; then
  1094.     echo shar: \"'proto.h'\" unpacked with wrong size!
  1095. fi
  1096. # end of 'proto.h'
  1097. fi
  1098. if test -f 'run.c' -a "${1}" != "-c" ; then 
  1099.   echo shar: Will not clobber existing file \"'run.c'\"
  1100. else
  1101. echo shar: Extracting \"'run.c'\" \(4716 characters\)
  1102. sed "s/^X//" >'run.c' <<'END_OF_FILE'
  1103. X
  1104. X/*
  1105. X * RUN.C
  1106. X *
  1107. X * (c)1986 Matthew Dillon     9 October 1986
  1108. X *
  1109. X *    RUN   handles running of external commands.
  1110. X *
  1111. X * Version 2.07M by Steve Drew 10-Sep-87
  1112. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1113. X * Version 5.00L by Urban Mueller 17-Feb-91
  1114. X *
  1115. X */
  1116. X
  1117. X#include "shell.h"
  1118. X
  1119. Xchar *rindex();
  1120. Xint MySyncRun( char *com, char *args, BPTR in, BPTR out );
  1121. Xint echofunc(void);
  1122. Xlong IoError;
  1123. X
  1124. Xint
  1125. Xdo_run( char *str )
  1126. X{
  1127. X    int retcode;
  1128. X    char buf[200]; /* enough space for 100 char cmd name + path stuff */
  1129. X    char *path, *argline, *trueargline, *copy, *ext, *dst, *end;
  1130. X
  1131. X    if( !*av[0] )
  1132. X        return 0;
  1133. X
  1134. X    if( (retcode=echofunc())>=0 )
  1135. X        return retcode;
  1136. X
  1137. X    a0tospace( av[0] );                                 /* allow "com mand" */
  1138. X
  1139. X    IoError=0;
  1140. X    if( ac==1 && (isdir(av[0]) || !strcmp( av[0],"..") || !strcmp(av[0],"~"))) {
  1141. X        if( !strcmp(av[0],"~") && (dst=get_var(LEVEL_SET,v_lcd)) )
  1142. X            sprintf(buf,"cd %s",dst);
  1143. X        else 
  1144. X            sprintf(buf,"cd %s",av[0]);
  1145. X        execute( buf );
  1146. X        return 0;
  1147. X    }
  1148. X
  1149. X    if( (IoError==218 || IoError==225 || IoError==226) && index(av[0],':')) {
  1150. X        ierror( av[0], IoError );
  1151. X        return 20;
  1152. X    }
  1153. X
  1154. X    argline=compile_av(av, 1, ac, ' ', 1);
  1155. X    trueargline= (*argline ? argline : "\n");
  1156. X
  1157. X    if (strlen(av[0]) > 100) { ierror(NULL,509); return -1; }
  1158. X
  1159. X    sprintf(buf,"res_%s",BaseName(av[0]));              /* delayed residents */
  1160. X    if (o_resident && Getenv(buf, buf+100, 90L) && loadres(av[0]))
  1161. X        Setenv(buf,NULL);
  1162. X
  1163. X    if( (retcode=MySyncRun(av[0],trueargline,0L,0L))>=0 )   /* AmigaDOS path */
  1164. X        goto done2;
  1165. X
  1166. X    strcpy(buf,"source ");
  1167. X    if (path = dofind(av[0],"",buf+7,v_path)) {             /* shell path    */
  1168. X        if((retcode = MySyncRun(path,trueargline,0L,0L))>=0)
  1169. X            goto done2;
  1170. X        else {
  1171. X            struct DPTR *dp;
  1172. X            int stat;
  1173. X            if(dp=dopen(path,&stat)) {
  1174. X                stat=dp->fib->fib_Protection & FIBF_SCRIPT;
  1175. X                dclose(dp);
  1176. X                if( stat ) {
  1177. X                    execute(buf);
  1178. X                    return 0;
  1179. X                }
  1180. X            }
  1181. X        }
  1182. X    }
  1183. X
  1184. X    if(!(end=rindex(av[0],'.'))) end="";               /* automatic sourcing */
  1185. X    ext=strcmp(end,".sh") ? ".sh" : "";
  1186. X    if (path = dofind(av[0],ext,buf,v_path)) {
  1187. X        av[1] = buf;
  1188. X        copy = malloc(strlen(str)+3);
  1189. X        sprintf(copy,"x %s",str);
  1190. X        retcode = do_source(copy);
  1191. X        goto done;
  1192. X    }
  1193. X
  1194. X    copy=malloc(strlen(av[0])+strlen(argline)+5);
  1195. X    sprintf(copy,"%s %s",av[0],trueargline);
  1196. X
  1197. X    ext=strcmp(end,".rexx") ? ".rexx" : "";           /* automatic rx-ing   */
  1198. X    if( path = dofind(av[0], ext, buf, v_rxpath )) {
  1199. X        if( (retcode=MySyncRun("rx",copy,0L,0L)) >=0 ) goto done;
  1200. X        if (path = dofind("rx","",buf,v_path)) {
  1201. X            retcode = MySyncRun(path,copy,0L,0L);
  1202. X            goto done;
  1203. X        }
  1204. X    }
  1205. X
  1206. X    if( !doaction(av[0],"exec",argline)) {
  1207. X        retcode=0;
  1208. X        goto done;
  1209. X    }
  1210. X
  1211. X    retcode=-1;
  1212. X    fprintf(stderr,"Command Not Found %s\n",av[0]);
  1213. X
  1214. Xdone:
  1215. X    free( copy );
  1216. Xdone2:
  1217. X    free( argline );
  1218. X    return retcode;
  1219. X}
  1220. X
  1221. Xstruct Segment {
  1222. X    BPTR NextEntry;
  1223. X    LONG UseCount;
  1224. X    BPTR SegPtr;
  1225. X    BSTR SegName;
  1226. X};
  1227. X
  1228. Xint
  1229. XMySyncRun( char *com, char *args, BPTR in, BPTR out )
  1230. X{
  1231. X    struct Segment *seg;
  1232. X    int ret;
  1233. X    char buf2[84], *buf=buf2;
  1234. X    long oldname;
  1235. X
  1236. X#ifdef KICK20
  1237. X    if( o_kick20 ) {
  1238. X        oldname = (long)Mycli->cli_CommandName;
  1239. X
  1240. X        while( (long)buf & 3 ) buf++;
  1241. X        buf[0] = strlen( com );
  1242. X        strncpy(buf+1,com,80);
  1243. X
  1244. X        Forbid();
  1245. X        seg=FindSegment( com, NULL, 0 );
  1246. X        Permit();
  1247. X        if( seg ) {
  1248. X            Mycli->cli_CommandName = (long)buf/4;
  1249. X            seg->UseCount++;
  1250. X
  1251. X            ret=RunCommand(seg->SegPtr, Mycli->cli_DefaultStack,
  1252. X                                             args, strlen(args));
  1253. X            seg->UseCount--;
  1254. X            Mycli->cli_CommandName = (long)oldname;
  1255. X            return ret;
  1256. X        }
  1257. X
  1258. X        if( o_internal ) {
  1259. X            Forbid();
  1260. X            seg=FindSegment( com, NULL, 1 );
  1261. X            Permit();
  1262. X            if( seg ) {
  1263. X                Mycli->cli_CommandName = (long)buf/4;
  1264. X
  1265. X                ret=RunCommand(seg->SegPtr, Mycli->cli_DefaultStack,
  1266. X                                                 args, strlen(args));
  1267. X                Mycli->cli_CommandName = (long)oldname;
  1268. X                return ret;
  1269. X            }
  1270. X        }
  1271. X
  1272. X    }
  1273. X#endif
  1274. X    if( (ret= SyncRun( com, args, in, out ))>=0 )
  1275. X        return ret;
  1276. X
  1277. X    return ret;
  1278. X}
  1279. X
  1280. Xint
  1281. Xdo_which( char *str )
  1282. X{
  1283. X    char *got, *com=av[1];
  1284. X
  1285. X    if( get_var(LEVEL_ALIAS,com) ) {
  1286. X        printf("Shell Alias '%s'\n",com);
  1287. X        return 0;
  1288. X    }
  1289. X
  1290. X    if( *(got=find_internal( com ))>1 ) {
  1291. X        printf("Shell Internal '%s'\n",got);
  1292. X        return 0;
  1293. X    }
  1294. X
  1295. X
  1296. X
  1297. X    printf( "Not found\n" );
  1298. X    return 20;
  1299. X}
  1300. X
  1301. X
  1302. Xchar *
  1303. Xdofind( char *cmd, char *ext, char *buf, char *path)
  1304. X{
  1305. X    char *ptr, *s=path;
  1306. X
  1307. X    Myprocess->pr_WindowPtr = (APTR)(-1);
  1308. X    sprintf(buf,"%s%s",cmd,ext);
  1309. X    if (exists(buf)) return buf;
  1310. X    if (BaseName(buf)==buf) {
  1311. X        if( *path=='_' )
  1312. X            s = get_var(LEVEL_SET, path);
  1313. X        while (*s) {
  1314. X            for (ptr=buf; *s && *s!=','; ) *ptr++ = *s++;
  1315. X            if( ptr[-1]!=':' && ptr[-1]!='/')
  1316. X                *ptr++='/';
  1317. X            sprintf(ptr, "%s%s", cmd, ext);
  1318. X            if (exists(buf)) {
  1319. X                Myprocess->pr_WindowPtr = (APTR)o_noreq;
  1320. X                return buf;
  1321. X            }
  1322. X            if (*s) s++;
  1323. X        }
  1324. X    }
  1325. X    Myprocess->pr_WindowPtr = (APTR)o_noreq;
  1326. X    return NULL;
  1327. X}
  1328. END_OF_FILE
  1329. if test 4716 -ne `wc -c <'run.c'`; then
  1330.     echo shar: \"'run.c'\" unpacked with wrong size!
  1331. fi
  1332. # end of 'run.c'
  1333. fi
  1334. if test -f 'sample.sh' -a "${1}" != "-c" ; then 
  1335.   echo shar: Will not clobber existing file \"'sample.sh'\"
  1336. else
  1337. echo shar: Extracting \"'sample.sh'\" \(926 characters\)
  1338. sed "s/^X//" >'sample.sh' <<'END_OF_FILE'
  1339. X# first a few useful aliases
  1340. X
  1341. Xal d   "dir -hq"  # hides .info and block lengths
  1342. Xal lst "ls -t"    # sorts by access time
  1343. Xal lsl "ls -l"    # sorts by length
  1344. X
  1345. X# sc searches *.c, even 'sc -c main()' works
  1346. X
  1347. Xal sc "%a search @pickopts( $a ) *.c @pickargs( $a )
  1348. X
  1349. X# edf edits a function in Cygnus Ed if the name starts in the first column:
  1350. X
  1351. Xal edf "%func set b \"\";search -afl *.c $func | inp b;\
  1352. X if $b;split b file line;ed $file;waitforport rexx_ced;\
  1353. X  inc line 1;rxs rexx_ced \"jump to file \"$file \"jumpto \"$line\" 0\";\
  1354. X else;\
  1355. X  echo Not found;\
  1356. X endif
  1357. X
  1358. X# this aliases suppress wild card expansion for certain commands
  1359. X
  1360. Xal zoo     "*a Zoo $a
  1361. Xal lharc   "*a Lharc $a
  1362. Xal lz      "*a Lz $a
  1363. Xal newlist "*a Newlist $a
  1364. X
  1365. X# pushd pushes the current directory on a stack
  1366. X# popd  retrieves it from there
  1367. X
  1368. Xset stk ""
  1369. Xal pushd   "set stk $_cwd @subwords( $stk 1 10 );"
  1370. Xal popd    "\\cd @first( $stk );set stk @subwords( $stk 2 10 );"
  1371. END_OF_FILE
  1372. if test 926 -ne `wc -c <'sample.sh'`; then
  1373.     echo shar: \"'sample.sh'\" unpacked with wrong size!
  1374. fi
  1375. # end of 'sample.sh'
  1376. fi
  1377. if test -f 'set.c' -a "${1}" != "-c" ; then 
  1378.   echo shar: Will not clobber existing file \"'set.c'\"
  1379. else
  1380. echo shar: Extracting \"'set.c'\" \(6486 characters\)
  1381. sed "s/^X//" >'set.c' <<'END_OF_FILE'
  1382. X
  1383. X/*
  1384. X * SET.C
  1385. X *
  1386. X * (c)1986 Matthew Dillon     9 October 1986
  1387. X *
  1388. X * Version 2.07M by Steve Drew 10-Sep-87
  1389. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1390. X * Version 5.00L by Urban Mueller 17-Feb-91
  1391. X *
  1392. X */
  1393. X
  1394. X#include "shell.h"
  1395. X
  1396. Xstatic char *sys_expand( char *str, char *t );
  1397. Xstatic void set_sys_var( char *name );
  1398. X
  1399. X#define MAXLEVELS (3+MAXSRC)
  1400. X#define HASH 32
  1401. X
  1402. Xtypedef struct VNode {
  1403. X    struct VNode *next;
  1404. X    char *text;
  1405. X    char name[1];
  1406. X} NODE;
  1407. X
  1408. Xtypedef struct VRoot {
  1409. X    NODE *first[HASH];
  1410. X} ROOT;
  1411. X
  1412. XROOT Mbase[ MAXLEVELS ];
  1413. X
  1414. Xvoid
  1415. Xset_var( int level, char *name, char *str )
  1416. X{
  1417. X    NODE **first=&Mbase[level].first[*name & HASH-1], *node;
  1418. X    char *t, c;
  1419. X
  1420. X    if( !str ) str="";
  1421. X
  1422. X    for( t=name; isalphanum(*t); t++ ) ;
  1423. X    c=*t; *t=0;
  1424. X
  1425. X    for( node=*first; node; node=node->next )
  1426. X        if( !strcmp( node->name, name) ) {
  1427. X            free( node->text );
  1428. X            goto copy;
  1429. X        }
  1430. X
  1431. X    node=malloc(sizeof(NODE) + strlen(name));
  1432. X    node->next=*first;
  1433. X    *first=node;
  1434. X    strcpy( node->name, name );
  1435. X
  1436. Xcopy:
  1437. X    node->text=strcpy( malloc(strlen(str)+1), str );
  1438. X    *t=c;
  1439. X    if( *name=='_' )
  1440. X        set_sys_var( name );
  1441. X}
  1442. X
  1443. X
  1444. Xchar *
  1445. Xget_var( int level, char *name )
  1446. X{
  1447. X    NODE *node=Mbase[level].first[*name & HASH-1];
  1448. X    char *t, c;
  1449. X
  1450. X    for ( t= name; *(signed char *)t > 0; t++ ) ; /*  *t!=0 && *t<0x80  */
  1451. X    c=*t; *t=0;
  1452. X
  1453. X    for( ; node; node=node->next )
  1454. X        if( !strcmp(node->name,name) )
  1455. X            { *t=c; return node->text; }
  1456. X    *t=c;
  1457. X    return NULL;
  1458. X}
  1459. X
  1460. Xvoid
  1461. Xunset_level( int level )
  1462. X{
  1463. X    NODE *node;
  1464. X    int i;
  1465. X
  1466. X    for( i=0; i<HASH; i++ ) {
  1467. X        for( node=Mbase[level].first[i]; node; node=node->next ) {
  1468. X            Free ( node->text );
  1469. X            Free ( node );
  1470. X        }
  1471. X        Mbase[level].first[i] = NULL;
  1472. X    }
  1473. X}
  1474. X
  1475. Xvoid
  1476. Xunset_var( int level, char *name )
  1477. X{
  1478. X    NODE **first=&Mbase[level].first[*name & HASH-1], *node, *prev;
  1479. X    char *t, c;
  1480. X
  1481. X    for( t=name; isalphanum(*t); t++ ) ;
  1482. X    c=*t; *t=0;
  1483. X
  1484. X    for( node=*first, prev=NULL; node; prev=node, node=node->next )
  1485. X        if( !strcmp( node->name, name) ) {
  1486. X            if( prev ) prev->next=node->next; else *first=node->next;
  1487. X            Free( node->text );
  1488. X            Free( node );
  1489. X            if( *name=='_' )
  1490. X                set_sys_var( name );
  1491. X            break;
  1492. X        }
  1493. X    *t=c;
  1494. X}
  1495. X
  1496. X
  1497. Xvoid
  1498. Xset_var_n( int level, char *name, char *str, int n )
  1499. X{
  1500. X    char c, len=strlen(str);
  1501. X
  1502. X    if( n>len )
  1503. X        n=len;
  1504. X
  1505. X    if( n>=0 ) {
  1506. X        c=str[n]; str[n]=0;
  1507. X        set_var( level, name, str );
  1508. X        str[n]=c;
  1509. X    } else 
  1510. X        set_var( level, name, "" );
  1511. X}
  1512. X
  1513. Xint
  1514. Xdo_unset_var( char *str, int level )
  1515. X{
  1516. X    int i;
  1517. X
  1518. X    for (i = 1; i < ac; ++i)
  1519. X        unset_var (level, av[i]);
  1520. X    return 0;
  1521. X}
  1522. X
  1523. Xint
  1524. Xdo_set_var( char *command, int level )
  1525. X{
  1526. X    ROOT *root = &Mbase[level];
  1527. X    NODE *node;
  1528. X    int i;
  1529. X    char *str;
  1530. X
  1531. X    switch (ac) {
  1532. X    case 1:
  1533. X        for( i=0; i<HASH && !breakcheck(); i++ )
  1534. X            for( node=root->first[i]; node && !dobreak(); node=node->next )
  1535. X                printf ("%s%-10s %s\n", o_lolite, node->name, node->text);
  1536. X        break;
  1537. X    case 2:
  1538. X        if (str=get_var(level,av[1])) printf ("%-10s %s\n", av[1], str);
  1539. X        break;
  1540. X    default:
  1541. X        set_var (level, av[1], next_word (next_word (command)));
  1542. X        break;
  1543. X    }
  1544. X    return 0;
  1545. X}
  1546. X
  1547. X
  1548. Xextern char shellvers[];
  1549. X
  1550. Xstatic char *
  1551. Xsys_expand( char *str, char *t )
  1552. X{
  1553. X    struct DateStamp dss;
  1554. X    DateStamp(&dss);
  1555. X
  1556. X    if( !str ) {
  1557. X        *t=0;
  1558. X        return t;
  1559. X    }
  1560. X
  1561. X    while (*str)
  1562. X        if (*str=='%') {
  1563. X            str+=2;
  1564. X            switch( str[-1] ) {
  1565. X            case 'p': t+=sprintf(t,"%s", get_var(LEVEL_SET, "_cwd")); break;
  1566. X            case 'm': t+=sprintf(t,"%d", AvailMem( 0 )/1024);         break;
  1567. X            case 't': t+=sprintf(t,"%s", next_word(dates(&dss)));     break;
  1568. X            case 'd':    sprintf(t,"%s", dates(&dss)); t=index(t,' ');break;
  1569. X            case 'c': t+=sprintf(t,"%s", o_hilite);                   break;
  1570. X            case 'v': t+=sprintf(t,"%s", shellvers );                 break;
  1571. X            case 'n': t+=sprintf(t,"%s", get_var(LEVEL_SET,"_clinumber"));break;
  1572. X            case 'h': t+=sprintf(t,"%s", get_var(LEVEL_SET, v_histnum));  break;
  1573. X            case 'f': t+=sprintf(t,"%s", oneinfo(get_var(LEVEL_SET,v_cwd),4));break;
  1574. X            case 'r': t+=sprintf(t,"%d", (SBYTE)Myprocess->pr_Task.tc_Node.ln_Pri);break;
  1575. X            default : *t++=str[-1];
  1576. X            }
  1577. X        }
  1578. X        else *t++=*str++;
  1579. X    *t=0;
  1580. X    return t;
  1581. X}
  1582. X
  1583. Xchar truetitle[200];
  1584. X
  1585. Xchar o_hilite[24], o_lolite[8], *o_csh_qcd, o_kick20, o_nobreak;
  1586. Xchar o_minrows, o_scroll, o_nowindow, o_noraw, o_vt100, o_nofastscr;
  1587. Xchar o_nobreak, o_bground, o_resident, o_internal;
  1588. Xlong o_noreq;
  1589. X
  1590. Xextern char trueprompt[100];
  1591. X
  1592. Xstatic void
  1593. Xset_sys_var( char *name )
  1594. X{
  1595. X    char *get, *str, c=name[1], col;
  1596. X
  1597. X    if( c==v_debug  [1] ) debug  =  get_var(LEVEL_SET,v_debug  )!=NULL;
  1598. X    if( c==v_verbose[1] ) Verbose=  get_var(LEVEL_SET,v_verbose)!=NULL;
  1599. X    if( c==v_nobreak[1] ) o_nobreak=get_var(LEVEL_SET,v_nobreak)!=NULL;
  1600. X    if( c==v_hilite [1] && !strcmp( name, v_hilite)) {
  1601. X        o_hilite[0]=o_lolite[0]=0;
  1602. X        get= get_var(LEVEL_SET,v_hilite);
  1603. X        str= o_hilite;
  1604. X        while( get && *get ) {
  1605. X            switch( *get++ ) {
  1606. X            case 'b': str+=sprintf( str, "\033[1m" ); break;
  1607. X            case 'i': str+=sprintf( str, "\033[3m" ); break;
  1608. X            case 'u': str+=sprintf( str, "\033[4m" ); break;
  1609. X            case 'r': str+=sprintf( str, "\033[7m" ); break;
  1610. X            case 'c': str+=strlen(str);
  1611. X                      if( *get>='0' && *get<='9' ) {
  1612. X                         col=*get++;
  1613. X                         if( *get==',' && get[1]>='0' && get[1]<='9' ) {
  1614. X                             str+=sprintf( str,"\033[3%cm\033[4%cm",col,get[1]);
  1615. X                             get+=2;
  1616. X                         } else 
  1617. X                             str+=sprintf( str,"\033[3%cm",col );
  1618. X                      }
  1619. X                      break;
  1620. X            }
  1621. X        }
  1622. X        *str=0;
  1623. X        if( *o_hilite )
  1624. X            strcpy(o_lolite,"\033[m");
  1625. X        strcpy(sys_expand(str,trueprompt),o_lolite);
  1626. X    }
  1627. X    if( c==v_scroll[1] ) {
  1628. X        o_scroll=0;
  1629. X        if( (str= get_var(LEVEL_SET,v_scroll))) {
  1630. X            o_scroll=atoi( str );
  1631. X            if( o_scroll<2 ) o_scroll=0;
  1632. X            if( o_scroll>8 ) o_scroll=8;
  1633. X        }
  1634. X    }
  1635. X    if( c==v_minrows[1] ) {
  1636. X        o_minrows=34;
  1637. X        if( (str= get_var(LEVEL_SET,v_minrows))) {
  1638. X            o_minrows=atoi( str );
  1639. X            if( o_minrows<8 )   o_minrows=8;
  1640. X            if( o_minrows>100 ) o_minrows=100, o_scroll=0;
  1641. X        }
  1642. X    }
  1643. X    if( c==v_qcd[1] ) {
  1644. X        o_csh_qcd="s:csh-qcd";
  1645. X        if( str=get_var(LEVEL_SET,v_qcd) )
  1646. X            o_csh_qcd=str;
  1647. X    }
  1648. X    if( c==v_noreq[1] ) {
  1649. X        o_noreq= get_var(LEVEL_SET,v_noreq ) ? -1 : 0;
  1650. X        Myprocess->pr_WindowPtr = (APTR)o_noreq;
  1651. X    }
  1652. X    if( c==v_hist[1] )
  1653. X        S_histlen=(str= get_var(LEVEL_SET, v_hist)) ? atoi(str) : 0;
  1654. X    if( c==v_titlebar[1] )
  1655. X        update_sys_var( v_titlebar );
  1656. X}
  1657. X
  1658. Xvoid
  1659. Xupdate_sys_var( char *name )
  1660. X{
  1661. X    char c=name[1], *str, buf[250];
  1662. X
  1663. X    if( c==v_prompt[1] ) {
  1664. X        if( (str=get_var(LEVEL_SET,v_prompt) ) ==NULL) str="$ ";
  1665. X        strcpy(sys_expand(str,trueprompt),o_lolite);
  1666. X    }
  1667. X    if( c==v_titlebar[1] && !o_nowindow && Win ) {
  1668. X        sys_expand( get_var(LEVEL_SET, v_titlebar), buf);
  1669. X        if (strcmp(Win->Title, buf)) {
  1670. X            strcpy(truetitle,buf);
  1671. X            SetWindowTitles(Win, truetitle, (char *)-1);
  1672. X        }
  1673. X    }
  1674. X}
  1675. END_OF_FILE
  1676. if test 6486 -ne `wc -c <'set.c'`; then
  1677.     echo shar: \"'set.c'\" unpacked with wrong size!
  1678. fi
  1679. # end of 'set.c'
  1680. fi
  1681. if test -f 'shell.doc.ac' -a "${1}" != "-c" ; then 
  1682.   echo shar: Will not clobber existing file \"'shell.doc.ac'\"
  1683. else
  1684. echo shar: Extracting \"'shell.doc.ac'\" \(10945 characters\)
  1685. sed "s/^X//" >'shell.doc.ac' <<'END_OF_FILE'
  1686. X      in the next chapter which aliases all those cases.
  1687. X    - because the 'if' command works differently now, variables with
  1688. X      embedded stand-alone '<' or '<=' type operators will cause problems
  1689. X      if they are on the left side in an 'if' statement:
  1690. X        set a b "<" c;if $a > x;echo b > x;end --> b > x
  1691. X    - A question mark '?' as the only argument to a command now shows the
  1692. X      usage of that command and does NOT pattern match.
  1693. X
  1694. XXII. EXAMPLE SOURCE FILES
  1695. X-------------------------
  1696. X
  1697. XIf from a CLI or the startup-script you say 'SHELL filename', that file is
  1698. Xsourced first.
  1699. X
  1700. X### compat.sh ###
  1701. X
  1702. X# this makes sure that your old abbreviations don't call new commands
  1703. X
  1704. Xalias as  aset
  1705. Xalias cl  close
  1706. Xalias g   goto
  1707. Xalias h   help
  1708. Xalias he  help
  1709. Xalias m   md
  1710. Xalias q   quit
  1711. Xalias re  rename
  1712. Xalias w   window
  1713. X
  1714. Xalias kr  "rm -r ram:* >NIL:
  1715. X
  1716. X### End of compat.sh ###
  1717. X
  1718. X
  1719. XMoreover, if you have a file called S:.login, it will be sourced for every
  1720. XShell you run. This is useful for aliases and setting that you want in ALL
  1721. XShells.
  1722. X
  1723. X
  1724. X### Example S:.login ###
  1725. X
  1726. XHere is an example .login file:
  1727. X
  1728. Xset F5 "cdir WORK:"^M
  1729. Xset f9 "ed s:login.sh"^M
  1730. Xset F9 "ed df0:s/startup-sequence"^M
  1731. X
  1732. Xalias toram  "%q foreach i ( $q ) \"cp -r $i: ram:$i >NIL:;assign $i: ram:$i
  1733. Xalias ramop  "md RAM:op; assign OP: ram:op
  1734. Xalias noop   "assign OP: ; rm -r ram:op
  1735. Xalias newop  "rm -r OP:*
  1736. Xalias dc     "dfc df0: to df1:
  1737. Xalias go     "%q assign WORK: Boot:$q; cd WORK:; source startme.sh
  1738. Xalias get    "%q cp $q RAM: >NIL:
  1739. Xalias filter "%a%b%c exec $b \\<$a \\>$c
  1740. X    # reads $a, filters it with $b and writes result to $c
  1741. X
  1742. Xalias rm     "%q \\rm @confirm( Remove $q )
  1743. X
  1744. X#alias rm     "%a set f @pickargs( $a );set opts @pickargs( $a );\
  1745. X# e -n OK to delete @words( @files( $f ) ) file(s) and @words( @dirs( $f ) )\
  1746. X# directories\"? \";input b;if $b = y;\\rm $opts $f;endif 
  1747. X#        # for the anxious among us: confirmed rm
  1748. X
  1749. Xset _prompt   "%c%p> "
  1750. X    # this puts the path highlighted in the prompt
  1751. X
  1752. X# this one puts cli number, free mem, date and time in title bar
  1753. Xset _titlebar "Shell %n    Mem %m     Date %d    Time %t
  1754. X
  1755. X# This file will be sourced for every Shell you start
  1756. X
  1757. X### End of example .login ###
  1758. X
  1759. X****************************************************************************
  1760. X
  1761. XIf you are a CLI user, your startup-sequence may be as simple as:
  1762. X
  1763. X    C:csh S:startup.sh
  1764. X
  1765. XHere is, my startup code:
  1766. X
  1767. X### Example S:startup.sh ###
  1768. X
  1769. Xwind -l    # if you are on a PAL machine, or use overscan
  1770. X    # note that commands may be abbreviated (wind=window)
  1771. X
  1772. Xassign LC: Stuff:c  INCLUDE: Stuff:include   LIB: Boot:lib   QUAD: RAM:
  1773. X
  1774. Xrback C:FaccII; sleep 1
  1775. X    # after spawning a process, it is always better to allow it
  1776. X    # to load the command, to avoid excessive drive head movement
  1777. X
  1778. Xresident -d blink lc1 lc2 >NIL:    #defer loading
  1779. X
  1780. XC:PopCli 300 C:Newcli         #using full pathname loads faster
  1781. XC:FF -1 Siesta.font >NIL:
  1782. XC:Patch_1 >NIL:
  1783. Xstack 8000            # lc1 and lc2 need this
  1784. X
  1785. Xsource S:setdate.sh        # this is listed next 
  1786. X
  1787. X### End of example startup.sh ###
  1788. X
  1789. X****************************************************************************
  1790. X
  1791. XThe following is an example source file to set date and time; it may be
  1792. Xused at startup if you don't have an internal clock.
  1793. X
  1794. X### setdate.sh ###
  1795. X
  1796. Xopen CON:200/100/440/80/SetDate write 1
  1797. Xecho >.1 -n "Current date is "
  1798. Xdate >.1
  1799. Xecho >.1 -n "Please enter date: "
  1800. Xinput <.1 d
  1801. Xclose 1
  1802. Xstrlen len $d
  1803. Xif $len > 1 ; date $d ; endif
  1804. Xecho -n "New date: " ; date
  1805. X
  1806. X### End of setdate.sh ###
  1807. X
  1808. X***************************************************************************
  1809. X
  1810. XNext comes a makefile that needs no Make program: may be executed from
  1811. XShell directely!!!
  1812. X
  1813. X### make.sh ###
  1814. X
  1815. Xif -t Shell.syms Shell.h; cc +HShell.syms Shell.h; rm shell.o; endif
  1816. Xif -t RAM:Shell.syms Shell.syms; cp -d Shell.syms RAM:; endif
  1817. X
  1818. Xforeach i ( main comm1 comm2 comm3 execom globals rawconsole run set \
  1819. X sub ) "if -t $i.o $i.c; echo Compile $i...;cc +IRAM:shell.syms $i.c; endif"
  1820. X
  1821. X# we used line continuation for better visibility. this is not necessary,
  1822. X# you can type it all in one line. note the limit of 256 bytes per line
  1823. X
  1824. Xif -t Shell run.o main.o comm1.o comm2.o comm3.o execom.o \
  1825. Xset.o sub.o globals.o rawconsole.o
  1826. X    ln  +q -m -o Shell run.o main.o comm1.o comm2.o comm3.o\
  1827. X    execom.o set.o sub.o globals.o rawconsole.o -la -lc
  1828. Xendif
  1829. X
  1830. X### End of make.sh ###
  1831. X
  1832. X
  1833. XXIII.  Default Values
  1834. X--------------------
  1835. X
  1836. XTo make things easier, some aliases are predefined whenever you start a
  1837. Xnew Shell. These are:
  1838. X
  1839. X    CLS
  1840. X    Simply clear the screen.
  1841. X
  1842. X    CDIR
  1843. X    Use "cdir directory" to clear the screen, set CD to directory,
  1844. X    and list it.
  1845. X
  1846. X    EXIT
  1847. X    Leave Shell and exit CLI.
  1848. X
  1849. X    FG
  1850. X    Runs current shell in foreground, this means priority 1.
  1851. X
  1852. X    KR
  1853. X    Used to delete everything on RAM:. This one is gone, if you still
  1854. X    want it, you'll have to put it in your s:.login
  1855. X
  1856. X    LP
  1857. X    List to printer one or more files.
  1858. X
  1859. X    MANLIST
  1860. X    Display  a list of possible arguments to man.  You can pipe this to
  1861. X    qsort to get a sorted output.
  1862. X
  1863. X    NICE
  1864. X    Sets this shell to priority -1.
  1865. X
  1866. XMoreover, many variables have default values, and many function keys are
  1867. Xpredefined. You can use set command to determine all of these.
  1868. X
  1869. XXIV.  Object oriented features
  1870. X------------------------------
  1871. X
  1872. X    CLASSES OF FILES
  1873. X
  1874. X    You can define a class of files using several 'class' commands.
  1875. X    Here a simple example:
  1876. X
  1877. X      class picture  suff=.pic suff=.iff suff=.ilbm 
  1878. X      class anim     suff=.anim
  1879. X
  1880. X    From now on, everything with the suffix .pic, .iff or .ilbm will
  1881. X    be identified as a picture. Please note that there may be no blanks
  1882. X    between the names and the '=', and that blanks inside the names
  1883. X    must be put in quotes. So these are the ways to identify a file:
  1884. X
  1885. X      suff=.doc        True if the suffix of the file is .doc
  1886. X      name=readme      True if the file is "readme"
  1887. X      offs=14,DC..C4FD True if the bytes starting at $14 are $DC,
  1888. X                       anything, $C4, $FD  (all numbers hexadecimal!). 
  1889. X                       Each pair of dots means one byte ignored.
  1890. X      chars            True if 90% of the bytes in the file are 32..127
  1891. X                       or 9..13
  1892. X      default          Always true, used to define the default type
  1893. X
  1894. X    Note that only the first character is examined, so 's' = 'suff'.
  1895. X    One class can be identified by more than one 'class' statement.
  1896. X    They are looked at in the same sequence they were entered. So to
  1897. X    make sure that an zoo archive misnamed as .lzh is identified
  1898. X    correctly, use the following 'class' statements:
  1899. X
  1900. X      class zoo offs=14,DCA7C4FD
  1901. X      class lzh offs=2,2D6C68..2D
  1902. X      class zoo suff=.zoo
  1903. X      class lzh suff=.lzh
  1904. X
  1905. X    Moreover, there is a builtin class 'dir', which means directory.
  1906. X    Now we know many file types. But what to do with them? This is
  1907. X    where we define 'actions'.
  1908. X
  1909. X    ACTIONS ON CLASSES
  1910. X
  1911. X    There may be one or more 'class' command that define what actions
  1912. X    need to be taken in various cases for that specific class:
  1913. X
  1914. X      class zoo actions view="zoo -list" extr="zoo -extract"
  1915. X      class lzh actions view="lz l"      extr="lz e"
  1916. X
  1917. X    Whenever somebody tries to 'view' a test.zoo, the command
  1918. X    'zoo -list test.zoo' will be issued, but if he tries to
  1919. X    view test.lzh, then 'lz l test.lzh' will be executed. Note
  1920. X    that any command supplied here goes through the normal csh
  1921. X    parser, so AmigaDOS and csh paths will be searched. Aliases
  1922. X    with arguments are allowed here, too, so whatever the user
  1923. X    typed will be stored in the variable after the '%'.
  1924. X
  1925. X    How do I tell a file that I want to 'view' it? There comes the
  1926. X    second command used for object oriented features:
  1927. X
  1928. X      action view test.zoo
  1929. X
  1930. X    will first identify the type of that file and then apply, if
  1931. X    possible, the 'view' action to it. Of course, this works best
  1932. X    inside an alias:  alias v "action view" will define a v-command
  1933. X    that views all types of files known to cshell. Similarly, you
  1934. X    can define   alias xtr "action extr" and use this command to
  1935. X    extract files from any type of archive.
  1936. X    There is one action that will be sent to every file that you
  1937. X    try to start but is not executable. This action is 'exec'. 
  1938. X    Assume you have defined the class 'picture', then after
  1939. X
  1940. X      class picture actions view=Mostra exec=Mostra
  1941. X
  1942. X    you can display a picture using Mostra by just typing its name.
  1943. X    More builtin actions like 'rm' and 'dir' may be implemented,
  1944. X    so don't use command names for action names.
  1945. X
  1946. X    The batch file class.sh defines a few useful classes.
  1947. X
  1948. X
  1949. X
  1950. XXV.     Keymaps
  1951. X---------------
  1952. X
  1953. X    You define a keymap as a collection of key/function pairs. Both
  1954. X    are given as numbers. There can be several keymaps which activate
  1955. X    each other, but at first we only edit keymap 0, which is active
  1956. X    at the beginning. All keys you define will eventually overwrite
  1957. X    the old definitions in an existing keymap. Everithing marked with
  1958. X    a (*) is not yet implemented.
  1959. X
  1960. X    KEYCODES
  1961. X
  1962. X    1..255    The corresponding ASCII character
  1963. X    256      Up Arrow
  1964. X    257      Down Arrow
  1965. X    258      Right Arrow
  1966. X    259      Left Arrow
  1967. X    260      Help
  1968. X    261..270  F1..F10  (unshifted)
  1969. X
  1970. X
  1971. X    Modifiers (add them to the key code)
  1972. X
  1973. X    512       SHIFT (only necessary for arrows and fkeys)
  1974. X    1024      ESC   (was pressed & released before this key)
  1975. X
  1976. X    EDITFUNCTIONS
  1977. X
  1978. X    - Movement      Move cursor...
  1979. X     0  CursLeft    1 left
  1980. X     1  CursRight   1 right
  1981. X     2  WordLeft    1 word left
  1982. X     3  WordRight   1 word right
  1983. X     4  BegOfLine   to beginning of line
  1984. X     5  EndOfLine   to end of line
  1985. X
  1986. X    - Deleting      Delete...
  1987. X    10  Backspace   char left from cursor
  1988. X    11  Delete      char right from cursor
  1989. X    12  BkspcWord   word left from cursor
  1990. X    13  DelWord     word right from cursor
  1991. X    14  DeleteToSOL to start of line
  1992. X    15  DeleteToEOL to end of line
  1993. X    16  DeleteLine  whole line
  1994. X
  1995. X    - History
  1996. X    20  Back        Move one line back in history
  1997. X    21  Forward     Move one line forward in history
  1998. X    22  Beg         Move to first line in history
  1999. X    23  End         Move to last line in history
  2000. X    24  Complete    History retrieve like '!'
  2001. X    25  Exec        Execute history line & bring up next
  2002. X    26  Tail        Insert previous line except first word
  2003. X
  2004. X    - Completion
  2005. X    30  Normal      Insert first matching file (or cycle)
  2006. X    31  Partial     Insert substring of all matching files
  2007. X    32  All         Insert all matching files
  2008. X    33  Directory   Find dir in quick cd list
  2009. X    34  LastCD      Insert last current directory
  2010. X
  2011. X    - Special
  2012. X    40  Insert      Toggle Insert/Overwrite
  2013. X    41  Quit        Silently perform 'quit'
  2014. X    42  Help        Silently perform 'help'
  2015. X    43  Refresh     Redraw current line
  2016. X    44  Execute     Execute current line
  2017. X    45  Leave       Edit new line, store this in hist
  2018. X    46  EOF         Terminate shell
  2019. X    47  NOP         Do nothing
  2020. X    48  Echo^O      Echoes a ^O
  2021. X    49  Beep        Echoes a ^G
  2022. X
  2023. X    - Other
  2024. X    50  Fkey        Execute command associated to last fkey
  2025. X    51  Menu        Execute command associated to last menu
  2026. X    52  Undo        Undoes last edit
  2027. X    53  Repeat      Repeats last function
  2028. X
  2029. X
  2030. X    Command types
  2031. X
  2032. X    0   +x      Editing function x, see above descriptions
  2033. X    512 +x      Setmap x,     x=0..7
  2034. X    1024+x      Insert key x, x=1..255
  2035. X    1536+x      Macro x       x=1..15         (*)
  2036. X    2048+x      String x      x=1..15         (*)
  2037. END_OF_FILE
  2038. if test 10945 -ne `wc -c <'shell.doc.ac'`; then
  2039.     echo shar: \"'shell.doc.ac'\" unpacked with wrong size!
  2040. fi
  2041. # end of 'shell.doc.ac'
  2042. fi
  2043. if test -f 'shell.h' -a "${1}" != "-c" ; then 
  2044.   echo shar: Will not clobber existing file \"'shell.h'\"
  2045. else
  2046. echo shar: Extracting \"'shell.h'\" \(5730 characters\)
  2047. sed "s/^X//" >'shell.h' <<'END_OF_FILE'
  2048. X
  2049. X/*
  2050. X * SHELL.H
  2051. X *
  2052. X * (c)1986 Matthew Dillon     9 October 1986
  2053. X *
  2054. X *
  2055. X * SHELL include file.. contains shell parameters and extern's
  2056. X *
  2057. X * Version 2.07M by Steve Drew 10-Sep-87
  2058. X *
  2059. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  2060. X *
  2061. X */
  2062. X
  2063. X#define RAW_CONSOLE 1   /* Set to 0 to compile out Cmd Line Editing */
  2064. X#define KICK20
  2065. X
  2066. X#define strlen strlen
  2067. X
  2068. X#include <exec/types.h>
  2069. X#include <exec/exec.h>
  2070. X#include <libraries/arpbase.h>
  2071. X#include <intuition/intuitionbase.h>
  2072. X#include <libraries/dosextens.h>
  2073. X#include <time.h>
  2074. X#include <ctype.h>
  2075. X#include <fcntl.h>
  2076. X#include <stdio.h>
  2077. X#include <stdlib.h>
  2078. X#include <string.h>
  2079. X#include "proto.h"
  2080. X
  2081. XLONG AssignLock( UBYTE *name, BPTR lock );
  2082. XBOOL AssignLate( UBYTE *name, UBYTE *path );
  2083. XBOOL AssignPath( UBYTE *name, UBYTE *path );
  2084. XBOOL AssignAdd( UBYTE *name, BPTR lock );
  2085. X
  2086. Xtypedef struct FileInfoBlock FIB;
  2087. X#ifdef AZTEC_C
  2088. X
  2089. X# include <functions.h>
  2090. X# define DEVTAB(x) _devtab[x->_unit].fd
  2091. X# define CHARSWAIT(x) (x->_bp < x->_bend)
  2092. X# define COMPILER "Aztec C 5.0d"
  2093. X# pragma amicall(DOSBase, 0x264, AssignLock(d1,d2))
  2094. X# pragma amicall(DOSBase, 0x26a, AssignLate(d1,d2))
  2095. X# pragma amicall(DOSBase, 0x270, AssignPath(d1,d2))
  2096. X# pragma amicall(DOSBase, 0x276, AssignAdd(d1,d2))
  2097. X
  2098. X#else
  2099. X
  2100. X# include <proto/all.h>
  2101. X# include <ios1.h>
  2102. X# define DEVTAB(x) _ufbs[(x)->_file].ufbfh
  2103. X# define CHARSWAIT(x) (x->_rcnt != x->_wcnt)
  2104. X
  2105. X  extern struct UFB _ufbs[];
  2106. X# define COMPILER "Lattice C 5.10"
  2107. X# define index strchr
  2108. X# define memmove(t,f,l) movmem((f),(t),(l))
  2109. X# define swapmem(x,y,z) swmem(x,y,z)
  2110. X# pragma libcall DOSBase AssignLock 264 2102
  2111. X# pragma libcall DOSBase AssignLate 26a 2102
  2112. X# pragma libcall DOSBase AssignPath 270 2102
  2113. X# pragma libcall DOSBase AssignAdd 276 2102
  2114. X
  2115. X#endif
  2116. X
  2117. X#ifndef MAX
  2118. X#define MAX(x,y) ((x)>(y) ? (x) : (y))
  2119. X#endif
  2120. X
  2121. X#ifdef KICK20
  2122. Xtypedef ULONG    Tag;
  2123. Xstruct TagItem    {
  2124. X    Tag        ti_Tag;
  2125. X    ULONG    ti_Data;
  2126. X};
  2127. X#define TAG_DONE   (0L)    /* terminates array of TagItems. ti_Data unused    */
  2128. X#define TAG_END    TAG_DONE
  2129. X#define    TAG_IGNORE (1L)    /* ignore this item, not end of array        */
  2130. X#define    TAG_MORE   (2L)    /* ti_Data is pointer to another array of TagItems
  2131. X                         * note that this tag terminates the current array */
  2132. X#define    TAG_SKIP   (3L)    /* skip this and the next ti_Data items        */
  2133. X#define TAG_USER (1L<<31) /* differentiates user tags from system tags*/
  2134. X
  2135. X/* definitions for the System() call */
  2136. X
  2137. Xenum {    SYS_Dummy = TAG_USER + 32,
  2138. X    SYS_Input,            /* specifies the input filehandle  */
  2139. X    SYS_Output,            /* specifies the output filehandle */
  2140. X    SYS_Asynch,            /* run asynch, close input/output on exit(!) */
  2141. X    SYS_UserShell,        /* send to user shell instead of boot shell */
  2142. X    SYS_CustomShell,    /* send to a specific shell (data is name) */
  2143. X};
  2144. X#endif
  2145. X
  2146. X#define MAXAV        256        /* Max. # of arguments            */
  2147. X#define MAXSRC        5        /* Max. # of source file levels    */
  2148. X#define MAXIF        10        /* Max. # of if levels            */
  2149. X#define MAXALIAS    20        /* Max. # of alias levels        */
  2150. X#define MAXMYFILES    9        /* Max. # of internal files        */
  2151. X
  2152. X#define LEVEL_SET        0        /* which variable list to use   */
  2153. X#define LEVEL_ALIAS        1
  2154. X#define LEVEL_LABEL        2
  2155. X#define LEVEL_SOURCE    2
  2156. X
  2157. X#define SBYTE signed char
  2158. X#define MAXITEMS 16
  2159. X#define MAXMENUS 6
  2160. X
  2161. X#ifndef NULL
  2162. X#define NULL 0L
  2163. X#endif
  2164. X
  2165. X#define CHECKBREAK() dobreak()
  2166. X
  2167. X#ifndef AZTEC_C
  2168. Xstruct _dev {
  2169. X    long  fd;
  2170. X    short mode;
  2171. X    };
  2172. X#endif
  2173. X
  2174. Xstruct HIST {
  2175. X    struct HIST *next, *prev;    /* doubly linked list */
  2176. X    char *line;                    /* line in history    */
  2177. X};
  2178. X
  2179. Xstruct PERROR {
  2180. X    int errnum;                    /* Format of global error lookup */
  2181. X    char *errstr;
  2182. X};
  2183. X
  2184. Xstruct DPTR {                    /* Format of directory fetch pointer */
  2185. X    BPTR lock;                    /* lock on directory   */
  2186. X    FIB *fib;                    /* mod'd fib for entry */
  2187. X    };
  2188. X
  2189. Xextern struct HIST *H_head, *H_tail;
  2190. Xextern struct PERROR Perror[];
  2191. Xextern struct DPTR *dopen();
  2192. Xextern char **av;
  2193. Xextern char *Current;
  2194. Xextern int  H_len, H_tail_base, H_stack;
  2195. Xextern int  E_stack;
  2196. Xextern int  Src_stack, If_stack, forward_goto;
  2197. Xextern int  ac;
  2198. Xextern int  max_ac;
  2199. Xextern int  debug, Rval, Verbose, disable, Quit;
  2200. Xextern int  Lastresult, atoierr;
  2201. Xextern int  Exec_abortline;
  2202. Xextern int   S_histlen;
  2203. Xextern unsigned int options;
  2204. Xextern long  Cin, Cout, Cout_append;
  2205. Xextern char *Cin_name, *Cout_name;
  2206. Xextern char  Cin_type,  Cout_type;  /* these variables are in transition */
  2207. Xextern char *Pipe1, *Pipe2;
  2208. X
  2209. Xextern FILE *Src_base[MAXSRC];
  2210. Xextern long Src_pos[MAXSRC];
  2211. Xextern int  Src_if[MAXSRC];
  2212. Xextern char If_base[MAXIF];
  2213. Xextern struct Process *Myprocess;
  2214. Xextern struct CommandLineInterface *Mycli;
  2215. X
  2216. Xextern struct ArpBase *ArpBase;
  2217. X
  2218. Xextern long atol(), Atol(), myatol();
  2219. X
  2220. Xextern char v_titlebar[], v_prompt[], v_hist[], v_histnum[], v_debug[],
  2221. X    v_verbose[], v_stat[], v_lasterr[], v_cwd[], v_except[], v_passed[],
  2222. X    v_path[], v_gotofwd[], v_linenum[], v_every[], v_lcd[], v_rxpath[],
  2223. X    v_hilite[], v_scroll[], v_minrows[], v_result[], v_qcd[], v_noreq[],
  2224. X    v_value[], v_nobreak[], v_bground[];
  2225. X
  2226. Xextern char o_hilite[], o_lolite[], *o_csh_qcd, o_internal;
  2227. Xextern char o_aux, o_minrows, o_scroll, o_nowindow, o_noraw, o_vt100;
  2228. Xextern char o_nofastscr, o_kick20, o_nobreak, o_bground, o_resident;
  2229. Xextern long o_noreq;
  2230. Xextern char Buf[], isalph[], confirmed, *classfile;
  2231. X
  2232. X/* #define isalphanum(x) isalph[x] */
  2233. X
  2234. Xtypedef struct file_info {
  2235. X    LONG flags;
  2236. X    LONG size;
  2237. X    LONG blocks;
  2238. X    char class[12];
  2239. X    struct DateStamp date;
  2240. X} FILEINFO;
  2241. X
  2242. Xtypedef struct Class {
  2243. X    struct Class *next;
  2244. X    char name[1];
  2245. X} CLASS;
  2246. X
  2247. Xextern CLASS *CRoot, *LastCRoot;
  2248. Xextern struct Window *Win;
  2249. X
  2250. X#if 1
  2251. XLONG RunCommand( BPTR seg, long stack, UBYTE *paramptr, long paramlen );
  2252. Xstruct Segment *FindSegment( UBYTE *name, struct Segment *seg, long system );
  2253. XLONG System( UBYTE *command, struct TagItem *tags );
  2254. X
  2255. X# pragma libcall DOSBase RunCommand 1f8 432104
  2256. X# pragma libcall DOSBase FindSegment 30c 32103
  2257. X# pragma libcall DOSBase System 25e 2102
  2258. X#endif
  2259. END_OF_FILE
  2260. if test 5730 -ne `wc -c <'shell.h'`; then
  2261.     echo shar: \"'shell.h'\" unpacked with wrong size!
  2262. fi
  2263. # end of 'shell.h'
  2264. fi
  2265. if test -f 'technotes.doc' -a "${1}" != "-c" ; then 
  2266.   echo shar: Will not clobber existing file \"'technotes.doc'\"
  2267. else
  2268. echo shar: Extracting \"'technotes.doc'\" \(2908 characters\)
  2269. sed "s/^X//" >'technotes.doc' <<'END_OF_FILE'
  2270. X        TECHINCAL NOTES FOR SHELL VERSION: 5.00 17-Feb-91
  2271. X        =================================================
  2272. X
  2273. XSTRUCTURE
  2274. X---------
  2275. X
  2276. XThe  heart  of  CShell  is  still the old parser of Matt Dillon, which went
  2277. Xthrough  its  first  major change in this version (Matt abused bit 7 of the
  2278. Xcharacters,  so  international characters would not work).  Everything else
  2279. Xwere  just  minor  enhancements, which are very useful, though.  It's quite
  2280. Xhard  to read, and it's huge (took me DAYS to understand it), but maybe all
  2281. Xinterpreters look like this...
  2282. X
  2283. XThe other side of the shell are the built in commands.  They look much like
  2284. XCLI commands in C, but they have helluva lot of support functions for their
  2285. Xneeds.
  2286. X
  2287. XTo  write a builtin command for CShell, you use the global variables av and
  2288. Xac  instead of argv and argc, and use printf() for output.  That's it.  Any
  2289. Xother changes, if necessary, will be done by me.
  2290. X
  2291. XEvery  builtin  command  has its equivalent as a C function with the prefix
  2292. Xdo_ (example:  do_addbuffers).  The are no hard coded jumps to any of those
  2293. Xfunctions,  instead there is a table with the descriptions of all functions
  2294. X(like  name, usage, minimum arguments and, last but not least, a pointer to
  2295. Xthat function).
  2296. X
  2297. XI'll  probably  create  a  .doc that descibes the insides of the thell more
  2298. Xprecisely, and distribute it along with the source if I find the time to do
  2299. Xit (not everybody is a 24 hour programmer like Matt :-)
  2300. X
  2301. XWHY BUILT IN COMMANDS?
  2302. X----------------------
  2303. X
  2304. XThe reasons why does C-Shell still relies heavily on internal
  2305. Xcommands:
  2306. X- They can take advantage from each other (e.g. class recognition in the
  2307. X  'dir' command, use of 'search' command in quick cd)
  2308. X- They have a fast calling sequence
  2309. X- They need no hard disk seeks, so the startup can be accelerated
  2310. X  significantly
  2311. X- They are shorter than external commands
  2312. X- And finally, if you don't like them, don't use them. The wasted resources
  2313. X  become more and more negligible nowadays.
  2314. X
  2315. XSOURCE
  2316. X------
  2317. X
  2318. XThe  source  for CShell is available, if you don't have it, request it from
  2319. Xme.   It consists of 10 modules, together 190K.  It is compilable under SAS
  2320. X(Lattice)  &  Manx  C,  although  the  executables produced by Manx are not
  2321. Xresidentable.   If you want to modify it, ask me for an up-to-date version
  2322. Xfirst.   You  may  not  release  modified  versions  (imagine  the chaos if
  2323. Xeverbody  releases his private csh), but if you send them to me, you have a
  2324. Xvery good chance that I'll build it in.  You'll be, of course, be mentioned
  2325. Xin the docs.
  2326. X
  2327. XEven  if  you  don't  intend to modify it, I still encourage you to get the
  2328. Xsource,  because  there  are  so many things you can look up there once you
  2329. Xneed  it  (did *you* know how to set the system date?).  I apologize for my
  2330. Xpoor to nonexistent comments, I'll go through again when I've got the time.
  2331. XAh,  yes,  that  famous  Dillon-formatting  is gone, now it's traditionally
  2332. Xformatted.
  2333. END_OF_FILE
  2334. if test 2908 -ne `wc -c <'technotes.doc'`; then
  2335.     echo shar: \"'technotes.doc'\" unpacked with wrong size!
  2336. fi
  2337. # end of 'technotes.doc'
  2338. fi
  2339. echo shar: End of archive 1 \(of 6\).
  2340. cp /dev/null ark1isdone
  2341. MISSING=""
  2342. for I in 1 2 3 4 5 6 ; do
  2343.     if test ! -f ark${I}isdone ; then
  2344.     MISSING="${MISSING} ${I}"
  2345.     fi
  2346. done
  2347. if test "${MISSING}" = "" ; then
  2348.     echo You have unpacked all 6 archives.
  2349.     rm -f ark[1-9]isdone
  2350. else
  2351.     echo You still need to unpack the following archives:
  2352.     echo "        " ${MISSING}
  2353. fi
  2354. ##  End of shell archive.
  2355. exit 0
  2356. -- 
  2357. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2358. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2359. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  2360.